use criterion::{criterion_group, criterion_main, Criterion}; use naturalneighbor::{Interpolator, Point}; use rand::Rng; fn benchmark(c: &mut Criterion) { let mut rng: rand::rngs::StdRng = rand::SeedableRng::from_seed([0; 32]); let n = 100000; let bound = 1000.0; let points = (0..n) .map(|_| Point { x: rng.gen::() * bound, y: rng.gen::() * bound, }) .collect::>(); let weights = (0..n).map(|_| rng.gen::()).collect::>(); let interpolator = Interpolator::new(&points); c.bench_function("interpolate", |b| { b.iter(|| { let _ = interpolator.interpolate( &weights, Point { x: bound / 2.0, y: bound / 2.0, }, ); }) }); } criterion_group!(benches, benchmark); criterion_main!(benches);