summaryrefslogtreecommitdiffstats
path: root/benches
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2020-07-03 09:06:42 -0400
committerTavian Barnes <tavianator@tavianator.com>2020-07-03 09:06:42 -0400
commit77b0033e83f11a194651123e42b7960c6e756657 (patch)
tree8899bd51e18d4a79872ac77ebc6eeadce2cd9d54 /benches
parentd314f33de39fd3b32d093c2fc2d59c0aeb92c655 (diff)
downloadacap-77b0033e83f11a194651123e42b7960c6e756657.tar.xz
Add methods for merging new neighbors into a vector in-place
Diffstat (limited to 'benches')
-rw-r--r--benches/benches.rs33
1 files changed, 25 insertions, 8 deletions
diff --git a/benches/benches.rs b/benches/benches.rs
index 39368d2..caed17c 100644
--- a/benches/benches.rs
+++ b/benches/benches.rs
@@ -65,17 +65,34 @@ fn bench_nearest_neighbors(c: &mut Criterion) {
let index = $type::from_iter(points.clone());
group.bench_function("nearest", |b| b.iter(
- || index.nearest(&target))
- );
+ || index.nearest(&target)
+ ));
group.bench_function("nearest_within", |b| b.iter(
- || index.nearest_within(&target, 0.1))
- );
+ || index.nearest_within(&target, 0.1)
+ ));
group.bench_function("k_nearest", |b| b.iter(
- || index.k_nearest(&target, 3))
- );
+ || index.k_nearest(&target, 3)
+ ));
group.bench_function("k_nearest_within", |b| b.iter(
- || index.k_nearest_within(&target, 3, 0.1))
- );
+ || index.k_nearest_within(&target, 3, 0.1)
+ ));
+
+ group.bench_function("merge_k_nearest", |b| b.iter_batched(
+ || Vec::with_capacity(3),
+ |mut n| {
+ index.merge_k_nearest(&target, 3, &mut n);
+ n
+ },
+ BatchSize::SmallInput,
+ ));
+ group.bench_function("merge_k_nearest_within", |b| b.iter_batched(
+ || Vec::with_capacity(3),
+ |mut n| {
+ index.merge_k_nearest_within(&target, 3, &mut n, 0.1);
+ n
+ },
+ BatchSize::SmallInput,
+ ));
group.finish();
};