-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathbbox_own_areas.rs
54 lines (45 loc) · 1.31 KB
/
bbox_own_areas.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#![feature(test)]
extern crate test;
use similari::examples::BoxGen2;
use similari::utils::clipping::bbox_own_areas::{
exclusively_owned_areas, exclusively_owned_areas_normalized_shares,
};
use test::Bencher;
#[bench]
fn bbox_own_areas_00010(b: &mut Bencher) {
bench_bbox_own_areas(10, b);
}
#[bench]
fn bbox_own_areas_00025(b: &mut Bencher) {
bench_bbox_own_areas(25, b);
}
#[bench]
fn bbox_own_areas_00050(b: &mut Bencher) {
bench_bbox_own_areas(50, b);
}
#[bench]
fn bbox_own_areas_00100(b: &mut Bencher) {
bench_bbox_own_areas(100, b);
}
fn bench_bbox_own_areas(objects: usize, b: &mut Bencher) {
let pos_drift = 20.0;
let box_drift = 5.0;
let mut iterators = Vec::default();
for i in 0..objects {
iterators.push(BoxGen2::new(
i as f32, i as f32, 10.0, 10.0, pos_drift, box_drift,
));
}
b.iter(|| {
let mut observations = Vec::new();
for i in &mut iterators {
let b = i.next();
observations.push(b.unwrap().into());
}
let input = observations.iter().collect::<Vec<_>>();
let polygons = exclusively_owned_areas(input.as_slice());
let areas =
exclusively_owned_areas_normalized_shares(input.as_slice(), polygons.as_slice());
assert_eq!(areas.len(), objects);
});
}