summaryrefslogtreecommitdiffstats
path: root/benches/benches.rs
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2020-05-25 22:56:45 -0400
committerTavian Barnes <tavianator@tavianator.com>2020-06-24 10:02:23 -0400
commitb6b5a0ad79b49387ca2e07331b7cb9810b832db2 (patch)
treeb645a6eb65a577ec6d351d0b1efdfc3dbf60384b /benches/benches.rs
parent1f73f8028fffce5c737412b9e8fb1b5145f67a33 (diff)
downloadacap-b6b5a0ad79b49387ca2e07331b7cb9810b832db2.tar.xz
vp: Implement vantage-point trees
Diffstat (limited to 'benches/benches.rs')
-rw-r--r--benches/benches.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/benches/benches.rs b/benches/benches.rs
index a43e731..8791845 100644
--- a/benches/benches.rs
+++ b/benches/benches.rs
@@ -2,6 +2,7 @@
use acap::euclid::Euclidean;
use acap::exhaustive::ExhaustiveSearch;
+use acap::vp::VpTree;
use acap::NearestNeighbors;
use criterion::{black_box, criterion_group, criterion_main, Criterion};
@@ -34,6 +35,7 @@ fn bench_from_iter(c: &mut Criterion) {
let mut group = c.benchmark_group("from_iter");
group.bench_function("ExhaustiveSearch", |b| b.iter(|| ExhaustiveSearch::from_iter(points.clone())));
+ group.bench_function("VpTree", |b| b.iter(|| VpTree::from_iter(points.clone())));
group.finish();
}
@@ -42,21 +44,26 @@ fn bench_nearest_neighbors(c: &mut Criterion) {
let target = black_box(Euclidean([0.0, 0.0, 0.0]));
let exhaustive = ExhaustiveSearch::from_iter(points.clone());
+ let vp_tree = VpTree::from_iter(points.clone());
let mut nearest = c.benchmark_group("NearestNeighbors::nearest");
nearest.bench_function("ExhaustiveSearch", |b| b.iter(|| exhaustive.nearest(&target)));
+ nearest.bench_function("VpTree", |b| b.iter(|| vp_tree.nearest(&target)));
nearest.finish();
let mut nearest_within = c.benchmark_group("NearestNeighbors::nearest_within");
nearest_within.bench_function("ExhaustiveSearch", |b| b.iter(|| exhaustive.nearest_within(&target, 0.1)));
+ nearest_within.bench_function("VpTree", |b| b.iter(|| vp_tree.nearest_within(&target, 0.1)));
nearest_within.finish();
let mut k_nearest = c.benchmark_group("NearestNeighbors::k_nearest");
k_nearest.bench_function("ExhaustiveSearch", |b| b.iter(|| exhaustive.k_nearest(&target, 3)));
+ k_nearest.bench_function("VpTree", |b| b.iter(|| vp_tree.k_nearest(&target, 3)));
k_nearest.finish();
let mut k_nearest_within = c.benchmark_group("NearestNeighbors::k_nearest_within");
k_nearest_within.bench_function("ExhaustiveSearch", |b| b.iter(|| exhaustive.k_nearest_within(&target, 3, 0.1)));
+ k_nearest_within.bench_function("VpTree", |b| b.iter(|| vp_tree.k_nearest_within(&target, 3, 0.1)));
k_nearest_within.finish();
}