diff --git a/src/bench.rs b/src/bench.rs index fd47c5d..6b2eb64 100644 --- a/src/bench.rs +++ b/src/bench.rs @@ -11,11 +11,11 @@ fn gen_random() -> f64 { rand::thread_rng().gen_range(0., 10000.) } -fn generate_points(point_count : usize) -> Vec { - let mut points : Vec = vec![]; +fn generate_points(point_count: usize) -> Vec { + let mut points: Vec = vec![]; - for i in 0 .. point_count { - points.push(Point3WithId::new(i as i32, gen_random(),gen_random(),gen_random())); + for i in 0..point_count { + points.push(Point3WithId::new(i as i32, gen_random(), gen_random(), gen_random())); } points @@ -54,7 +54,7 @@ fn bench_adding_same_node_to_1000_tree(b: &mut Bencher) { let mut points = generate_points(len); let mut tree = kdtree::kdtree::Kdtree::new(&mut points); - let point = Point3WithId::new(-1 as i32, gen_random(),gen_random(),gen_random()); + let point = Point3WithId::new(-1 as i32, gen_random(), gen_random(), gen_random()); b.iter(|| { tree.insert_node(point); }); @@ -62,5 +62,5 @@ fn bench_adding_same_node_to_1000_tree(b: &mut Bencher) { -benchmark_group!(benches, /* bench_creating_1000_node_tree, */ bench_single_loop_times_for_1000_node_tree /*,bench_adding_same_node_to_1000_tree */); +benchmark_group!(benches, bench_creating_1000_node_tree, bench_single_loop_times_for_1000_node_tree,bench_adding_same_node_to_1000_tree); benchmark_main!(benches); \ No newline at end of file diff --git a/src/kdtree/test_common.rs b/src/kdtree/test_common.rs index d8c8b2a..c37a598 100644 --- a/src/kdtree/test_common.rs +++ b/src/kdtree/test_common.rs @@ -16,6 +16,7 @@ impl Point3WithId { } impl KdtreePointTrait for Point3WithId { + #[inline] fn dims(&self) -> &[f64] { return &self.dims; } @@ -37,6 +38,7 @@ impl Point2WithId { } impl KdtreePointTrait for Point2WithId { + #[inline] fn dims(&self) -> &[f64] { return &self.dims; } @@ -58,6 +60,7 @@ impl Point1WithId { } impl KdtreePointTrait for Point1WithId { + #[inline] fn dims(&self) -> &[f64] { return &self.dims; }