|
12 | 12 | //! column-x-column arms are the control: no operand is constant, so a prepared path has nothing to |
13 | 13 | //! hoist and must not regress them. |
14 | 14 | //! |
15 | | -//! `contains` has no all-overlapping arm. One `contains(query polygon, contained square)` row |
16 | | -//! builds a topology graph over the constant's 128 edges, which CodSpeed's CPU simulation charges |
17 | | -//! around 120 µs, so no row count both fits the per-iteration budget and exercises the row loop. |
18 | | -//! [`intersects::polygons_overlapping_x_constant`] covers the never-rejects case instead. |
19 | | -//! |
20 | 15 | //! Run with `cargo bench -p vortex-spatial --bench binary_predicates`. |
21 | 16 |
|
22 | 17 | #![expect(clippy::unwrap_used)] |
@@ -64,6 +59,10 @@ const ROWS: usize = 1 << 5; |
64 | 59 | /// pairwise predicate. It needs a smaller fixture than [`ROWS`] to stay inside the same budget. |
65 | 60 | const OVERLAPPING_POLYGON_ROWS: usize = 1 << 4; |
66 | 61 |
|
| 62 | +/// Containment builds a topology graph for each polygon pair. Four rows fit the benchmark budget |
| 63 | +/// while exercising construction followed by reuse of the prepared constant geometry. |
| 64 | +const CONTAINED_POLYGON_ROWS: usize = 4; |
| 65 | + |
67 | 66 | /// Deterministic pseudo-random value in `[0, 1)`. |
68 | 67 | fn unit(i: usize) -> f64 { |
69 | 68 | ((i.wrapping_mul(2654435761) >> 8) % 10_000) as f64 / 10_000.0 |
@@ -225,6 +224,23 @@ mod contains { |
225 | 224 | }); |
226 | 225 | } |
227 | 226 |
|
| 227 | + /// Constant container against contained polygons: every bbox check passes, the first row |
| 228 | + /// prepares the constant geometry, and the remaining rows reuse it for the full predicate. |
| 229 | + #[divan::bench] |
| 230 | + fn constant_x_polygons_overlapping(bencher: Bencher) { |
| 231 | + let mut ctx = SESSION.create_execution_ctx(); |
| 232 | + let query = query_constant(&mut ctx, CONTAINED_POLYGON_ROWS); |
| 233 | + let polygons = squares_mostly_overlapping(CONTAINED_POLYGON_ROWS); |
| 234 | + bencher |
| 235 | + .counter(ItemsCount::new(CONTAINED_POLYGON_ROWS)) |
| 236 | + .bench_local(|| { |
| 237 | + execute( |
| 238 | + SpatialContains::try_new_array(query.clone(), polygons.clone()), |
| 239 | + &mut ctx, |
| 240 | + ) |
| 241 | + }); |
| 242 | + } |
| 243 | + |
228 | 244 | /// Constant container against a point column with one null row in eight. |
229 | 245 | #[divan::bench] |
230 | 246 | fn constant_x_nullable_points(bencher: Bencher) { |
|
0 commit comments