|
1 | 1 | use std::f64::consts::PI;
|
2 | 2 |
|
3 | 3 | use criterion::{measurement::Measurement, *};
|
4 |
| -use geo::{ |
5 |
| - algorithm::{BooleanOps, Rotate}, |
6 |
| - Relate, |
7 |
| -}; |
| 4 | +use geo::algorithm::{BooleanOps, Rotate}; |
8 | 5 |
|
9 |
| -use geo_booleanop::boolean::BooleanOp as OtherBooleanOp; |
10 | 6 | use rand::{thread_rng, Rng};
|
11 | 7 | use rand_distr::Standard;
|
12 | 8 |
|
@@ -60,33 +56,39 @@ fn run_complex<T: Measurement>(c: &mut Criterion<T>) {
|
60 | 56 | );
|
61 | 57 | });
|
62 | 58 |
|
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, _| { |
67 | 77 | b.iter_batched(
|
68 | 78 | polys.sampler(),
|
69 |
| - |(_, _, poly, poly2)| OtherBooleanOp::intersection(poly, poly2), |
| 79 | + |(_, _, poly, poly2)| OtherBooleanOp::union(poly, poly2), |
70 | 80 | BatchSize::SmallInput,
|
71 | 81 | );
|
72 |
| - }, |
73 |
| - ); |
| 82 | + }); |
74 | 83 |
|
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 | + } |
90 | 92 | });
|
91 | 93 | }
|
92 | 94 |
|
|
0 commit comments