Skip to content

Commit 996cb46

Browse files
committed
only bench local boolop impl by default
bench in less than half the time.
1 parent d20ff89 commit 996cb46

File tree

2 files changed

+33
-27
lines changed

2 files changed

+33
-27
lines changed

geo-bool-ops-benches/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ edition = "2021"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

8+
[features]
9+
# If you want to bench against the `geo-booleanop` crate as a comparison, enable this feature.
10+
bench-foreign-booleanop = []
11+
812
[dependencies]
913
geo = { path = "../geo" }
1014
geo-types = { path = "../geo-types" }

geo-bool-ops-benches/benches/boolean_ops.rs

+29-27
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
use std::f64::consts::PI;
22

33
use criterion::{measurement::Measurement, *};
4-
use geo::{
5-
algorithm::{BooleanOps, Rotate},
6-
Relate,
7-
};
4+
use geo::algorithm::{BooleanOps, Rotate};
85

9-
use geo_booleanop::boolean::BooleanOp as OtherBooleanOp;
106
use rand::{thread_rng, Rng};
117
use rand_distr::Standard;
128

@@ -60,33 +56,39 @@ fn run_complex<T: Measurement>(c: &mut Criterion<T>) {
6056
);
6157
});
6258

63-
group.bench_with_input(
64-
BenchmarkId::new("rgbops::intersection", steps),
65-
&(),
66-
|b, _| {
59+
#[cfg(feature = "bench-foreign-booleanop")]
60+
{
61+
use geo::algorithm::Relate;
62+
use geo_booleanop::boolean::BooleanOp as OtherBooleanOp;
63+
64+
group.bench_with_input(
65+
BenchmarkId::new("rgbops::intersection", steps),
66+
&(),
67+
|b, _| {
68+
b.iter_batched(
69+
polys.sampler(),
70+
|(_, _, poly, poly2)| OtherBooleanOp::intersection(poly, poly2),
71+
BatchSize::SmallInput,
72+
);
73+
},
74+
);
75+
76+
group.bench_with_input(BenchmarkId::new("rgbops::union", steps), &(), |b, _| {
6777
b.iter_batched(
6878
polys.sampler(),
69-
|(_, _, poly, poly2)| OtherBooleanOp::intersection(poly, poly2),
79+
|(_, _, poly, poly2)| OtherBooleanOp::union(poly, poly2),
7080
BatchSize::SmallInput,
7181
);
72-
},
73-
);
82+
});
7483

75-
group.bench_with_input(BenchmarkId::new("rgbops::union", steps), &(), |b, _| {
76-
b.iter_batched(
77-
polys.sampler(),
78-
|(_, _, poly, poly2)| OtherBooleanOp::union(poly, poly2),
79-
BatchSize::SmallInput,
80-
);
81-
});
82-
83-
group.bench_with_input(BenchmarkId::new("geo::relate", steps), &(), |b, _| {
84-
b.iter_batched(
85-
polys.sampler(),
86-
|(poly, poly2, _, _)| poly.relate(poly2).is_intersects(),
87-
BatchSize::SmallInput,
88-
);
89-
});
84+
group.bench_with_input(BenchmarkId::new("geo::relate", steps), &(), |b, _| {
85+
b.iter_batched(
86+
polys.sampler(),
87+
|(poly, poly2, _, _)| poly.relate(poly2).is_intersects(),
88+
BatchSize::SmallInput,
89+
);
90+
});
91+
}
9092
});
9193
}
9294

0 commit comments

Comments
 (0)