From 237e58fa8d38055e2f1d69ba3a7828b5981a32e7 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Fri, 2 Dec 2022 11:39:40 -0500 Subject: [PATCH 1/5] Add WindingOrder benchmark --- geo/Cargo.toml | 4 ++ geo/benches/winding_order.rs | 82 ++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 geo/benches/winding_order.rs diff --git a/geo/Cargo.toml b/geo/Cargo.toml index b359ad3d2..001b4687c 100644 --- a/geo/Cargo.toml +++ b/geo/Cargo.toml @@ -98,3 +98,7 @@ harness = false [[bench]] name = "rand_line_crossings" harness = false + +[[bench]] +name = "winding_order" +harness = false diff --git a/geo/benches/winding_order.rs b/geo/benches/winding_order.rs new file mode 100644 index 000000000..f3af601da --- /dev/null +++ b/geo/benches/winding_order.rs @@ -0,0 +1,82 @@ +#[macro_use] +extern crate criterion; +extern crate geo; + +use geo::prelude::*; + +fn criterion_benchmark(c: &mut criterion::Criterion) { + c.bench_function("winding order: winding_order (f32)", |bencher| { + let ls = geo_test_fixtures::louisiana::(); + + bencher.iter(|| { + let _ = criterion::black_box( + criterion::black_box(&ls).winding_order(), + ); + }); + }); + + c.bench_function("winding order: winding_order (f64)", |bencher| { + let ls = geo_test_fixtures::louisiana::(); + + bencher.iter(|| { + let _ = criterion::black_box( + criterion::black_box(&ls).winding_order(), + ); + }); + }); + + c.bench_function("winding order: points_cw (f32)", |bencher| { + let ls = geo_test_fixtures::louisiana::(); + + bencher.iter(|| { + let points_iter = criterion::black_box( + criterion::black_box(&ls).points_cw(), + ); + for point in points_iter.0 { + criterion::black_box(point); + } + }); + }); + + c.bench_function("winding order: points_cw (f64)", |bencher| { + let ls = geo_test_fixtures::louisiana::(); + + bencher.iter(|| { + let points_iter = criterion::black_box( + criterion::black_box(&ls).points_cw(), + ); + for point in points_iter.0 { + criterion::black_box(point); + } + }); + }); + + c.bench_function("winding order: points_ccw (f32)", |bencher| { + let ls = geo_test_fixtures::louisiana::(); + + bencher.iter(|| { + let points_iter = criterion::black_box( + criterion::black_box(&ls).points_ccw(), + ); + for point in points_iter.0 { + criterion::black_box(point); + } + }); + }); + + c.bench_function("winding order: points_ccw (f64)", |bencher| { + let ls = geo_test_fixtures::louisiana::(); + + bencher.iter(|| { + let points_iter = criterion::black_box( + criterion::black_box(&ls).points_ccw(), + ); + for point in points_iter.0 { + criterion::black_box(point); + } + }); + }); +} + +criterion_group!(benches, criterion_benchmark); +criterion_main!(benches); From 0806761a35be342f3d126934bb34f2d8b242e431 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Fri, 2 Dec 2022 12:25:40 -0500 Subject: [PATCH 2/5] fix compilation --- geo/benches/winding_order.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/geo/benches/winding_order.rs b/geo/benches/winding_order.rs index f3af601da..5a687eba8 100644 --- a/geo/benches/winding_order.rs +++ b/geo/benches/winding_order.rs @@ -32,7 +32,7 @@ fn criterion_benchmark(c: &mut criterion::Criterion) { let points_iter = criterion::black_box( criterion::black_box(&ls).points_cw(), ); - for point in points_iter.0 { + for point in points_iter { criterion::black_box(point); } }); @@ -45,7 +45,7 @@ fn criterion_benchmark(c: &mut criterion::Criterion) { let points_iter = criterion::black_box( criterion::black_box(&ls).points_cw(), ); - for point in points_iter.0 { + for point in points_iter { criterion::black_box(point); } }); @@ -58,7 +58,7 @@ fn criterion_benchmark(c: &mut criterion::Criterion) { let points_iter = criterion::black_box( criterion::black_box(&ls).points_ccw(), ); - for point in points_iter.0 { + for point in points_iter { criterion::black_box(point); } }); @@ -71,7 +71,7 @@ fn criterion_benchmark(c: &mut criterion::Criterion) { let points_iter = criterion::black_box( criterion::black_box(&ls).points_ccw(), ); - for point in points_iter.0 { + for point in points_iter { criterion::black_box(point); } }); From ff5b185b3b46c2e5b9a01ff11b7b09f27f96ca8b Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Fri, 2 Dec 2022 12:34:16 -0500 Subject: [PATCH 3/5] Update geo/benches/winding_order.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Laurențiu Nicola --- geo/benches/winding_order.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geo/benches/winding_order.rs b/geo/benches/winding_order.rs index 5a687eba8..eb02304e4 100644 --- a/geo/benches/winding_order.rs +++ b/geo/benches/winding_order.rs @@ -39,7 +39,7 @@ fn criterion_benchmark(c: &mut criterion::Criterion) { }); c.bench_function("winding order: points_cw (f64)", |bencher| { - let ls = geo_test_fixtures::louisiana::(); + let ls = geo_test_fixtures::louisiana::(); bencher.iter(|| { let points_iter = criterion::black_box( From 6cbb9f1f558c84c7466418fdcc4ba7893d4e55c3 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Fri, 2 Dec 2022 12:34:22 -0500 Subject: [PATCH 4/5] Update geo/benches/winding_order.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Laurențiu Nicola --- geo/benches/winding_order.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geo/benches/winding_order.rs b/geo/benches/winding_order.rs index eb02304e4..5241d849e 100644 --- a/geo/benches/winding_order.rs +++ b/geo/benches/winding_order.rs @@ -65,7 +65,7 @@ fn criterion_benchmark(c: &mut criterion::Criterion) { }); c.bench_function("winding order: points_ccw (f64)", |bencher| { - let ls = geo_test_fixtures::louisiana::(); + let ls = geo_test_fixtures::louisiana::(); bencher.iter(|| { let points_iter = criterion::black_box( From 5bde9cbd895e08ffe5aa744851083ddc1a640664 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Fri, 2 Dec 2022 12:34:51 -0500 Subject: [PATCH 5/5] lint --- geo/benches/winding_order.rs | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/geo/benches/winding_order.rs b/geo/benches/winding_order.rs index 5241d849e..219947e94 100644 --- a/geo/benches/winding_order.rs +++ b/geo/benches/winding_order.rs @@ -9,9 +9,7 @@ fn criterion_benchmark(c: &mut criterion::Criterion) { let ls = geo_test_fixtures::louisiana::(); bencher.iter(|| { - let _ = criterion::black_box( - criterion::black_box(&ls).winding_order(), - ); + let _ = criterion::black_box(criterion::black_box(&ls).winding_order()); }); }); @@ -19,9 +17,7 @@ fn criterion_benchmark(c: &mut criterion::Criterion) { let ls = geo_test_fixtures::louisiana::(); bencher.iter(|| { - let _ = criterion::black_box( - criterion::black_box(&ls).winding_order(), - ); + let _ = criterion::black_box(criterion::black_box(&ls).winding_order()); }); }); @@ -29,9 +25,7 @@ fn criterion_benchmark(c: &mut criterion::Criterion) { let ls = geo_test_fixtures::louisiana::(); bencher.iter(|| { - let points_iter = criterion::black_box( - criterion::black_box(&ls).points_cw(), - ); + let points_iter = criterion::black_box(criterion::black_box(&ls).points_cw()); for point in points_iter { criterion::black_box(point); } @@ -42,9 +36,7 @@ fn criterion_benchmark(c: &mut criterion::Criterion) { let ls = geo_test_fixtures::louisiana::(); bencher.iter(|| { - let points_iter = criterion::black_box( - criterion::black_box(&ls).points_cw(), - ); + let points_iter = criterion::black_box(criterion::black_box(&ls).points_cw()); for point in points_iter { criterion::black_box(point); } @@ -55,9 +47,7 @@ fn criterion_benchmark(c: &mut criterion::Criterion) { let ls = geo_test_fixtures::louisiana::(); bencher.iter(|| { - let points_iter = criterion::black_box( - criterion::black_box(&ls).points_ccw(), - ); + let points_iter = criterion::black_box(criterion::black_box(&ls).points_ccw()); for point in points_iter { criterion::black_box(point); } @@ -68,9 +58,7 @@ fn criterion_benchmark(c: &mut criterion::Criterion) { let ls = geo_test_fixtures::louisiana::(); bencher.iter(|| { - let points_iter = criterion::black_box( - criterion::black_box(&ls).points_ccw(), - ); + let points_iter = criterion::black_box(criterion::black_box(&ls).points_ccw()); for point in points_iter { criterion::black_box(point); }