-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
83 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#[macro_use] | ||
extern crate criterion; | ||
extern crate geo; | ||
|
||
use criterion::Criterion; | ||
use geo::{intersects::Intersects, Coordinate, Line, LineString, Polygon}; | ||
|
||
|
||
fn criterion_benchmark(c: &mut Criterion) { | ||
let big: Vec<[f64;2 ]> = include!("../src/algorithm/test_fixtures/big.rs"); | ||
let norway: Vec<[f64;2 ]> = include!("../src/algorithm/test_fixtures/norway_main.rs"); | ||
c.bench_function("Large Polygon-Line intersection", |bencher| { | ||
let polygon = { | ||
let exterior = LineString::<f64>::from(big.clone()); | ||
Polygon::new(exterior, vec![]) | ||
}; | ||
let line = Line::new( | ||
Coordinate { x: 49.92187499999999, y: 70.95969716686398 }, | ||
Coordinate { x: 55.1953125, y: 62.59334083012024 } | ||
); | ||
|
||
bencher.iter(|| { | ||
criterion::black_box( | ||
criterion::black_box(&polygon).intersects(criterion::black_box(&line)), | ||
); | ||
}); | ||
}); | ||
|
||
c.bench_function("Polygon-Polygon intersection", |bencher| { | ||
|
||
let polygon_big = { | ||
let exterior = LineString::<f64>::from(big.clone()); | ||
Polygon::new(exterior, vec![]) | ||
}; | ||
let polygon_norway = { | ||
let exterior = LineString::<f64>::from(norway.clone()); | ||
Polygon::new(exterior, vec![]) | ||
}; | ||
|
||
bencher.iter(|| { | ||
criterion::black_box( | ||
criterion::black_box(&polygon_big).intersects(criterion::black_box(&polygon_norway)), | ||
); | ||
}); | ||
}); | ||
} | ||
|
||
criterion_group!(benches, criterion_benchmark); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters