fix: refactors knn and distance functions

This commit is contained in:
Volodymyr Orlov
2020-02-21 18:54:50 -08:00
parent 0e89113297
commit fe50509d3b
8 changed files with 101 additions and 154 deletions
+2 -5
View File
@@ -1,17 +1,14 @@
#[macro_use]
extern crate criterion;
extern crate smartcore;
extern crate ndarray;
use ndarray::{Array, Array1};
use smartcore::math::distance::Distance;
use criterion::Criterion;
use criterion::black_box;
fn criterion_benchmark(c: &mut Criterion) {
let a = Array::from_vec(vec![1., 2., 3.]);
let a = vec![1., 2., 3.];
c.bench_function("Euclidean Distance", move |b| b.iter(|| Array1::distance(black_box(&a), black_box(&a))));
c.bench_function("Euclidean Distance", move |b| b.iter(|| smartcore::math::distance::euclidian::distance(black_box(&a), black_box(&a))));
}
criterion_group!(benches, criterion_benchmark);