Measure a spatial query on your workload#
Compare the same answer at the point where each workflow makes it usable. Start with the stored taxi-pickup and building query, then substitute your own layers, predicate, units and result columns.
Check that both queries answer the same question#
The sample uses local Parquet layers containing WKB pickup points and building polygons. The files declare no CRS. The distance threshold is 0.0045 in their source-coordinate units. It is a distance in meters only if the coordinates themselves use meters.
Run this candidate from the repository root of a Geometry checkout containing the two fixtures.
from pathlib import Path
import cugeo.geometry as geo
data = Path("crates/execution/tests/fixtures/spatialbench-q8-local-files")
tables = {
"trip": geo.table_from_file(data / "trip.parquet"),
"building": geo.table_from_file(data / "building.parquet"),
}
query = """
SELECT b.b_buildingkey, b.b_name, COUNT(*) AS nearby_pickup_count
FROM trip t JOIN building b
ON ST_DWithin(ST_GeomFromWKB(t.t_pickuploc),
ST_GeomFromWKB(b.b_boundary), 0.0045)
GROUP BY b.b_buildingkey, b.b_name
ORDER BY nearby_pickup_count DESC, b.b_buildingkey ASC
LIMIT 100
"""
result = geo.sql(query, tables=tables)
candidate_rows = result.rows
Run your baseline against the same files with an equivalent predicate, grouping, ordering and limit. Print whether the ordered keys, names and counts agree with the candidate. If a tie on count and key explains a discrepancy, report it. Resolve discrepancies before interpreting timings.
Time through the point where you use the answer#
Define the same start and finish for both workflows. For a host table, finish after delivery to host memory. For repeated queries on registered inputs, report registration separately and time each repetition through completed consumption. Account for outstanding device work at the endpoint.
If the consumer reads chunks, consume every chunk and record the reader’s streamed flag. A measurement that stops after the first chunk is time to first delivery, rather than time to consume the answer.
Read the comparison#
Have the harness print these facts alongside every comparison.
Parity, input sizes and returned row count.
Hardware and software or build identity.
Input and output placement, timing boundaries, and whether setup is cold or reused.
Elapsed time for each repetition of each path.
Calculate a ratio only for runs with comparable endpoints. A small job may take longer on the GPU. To test batching, hold the total independent work constant and report each batch size with its measurements. State the conclusion with the workload, timing scope and hardware.