-
Notifications
You must be signed in to change notification settings - Fork 14
/
nms.rs
53 lines (43 loc) · 986 Bytes
/
nms.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
#![feature(test)]
extern crate test;
use similari::examples::BoxGen2;
use similari::utils::nms::nms;
use test::Bencher;
#[bench]
fn nms_00010(b: &mut Bencher) {
bench_nms(10, b);
}
#[bench]
fn nms_00100(b: &mut Bencher) {
bench_nms(100, b);
}
#[bench]
fn nms_00300(b: &mut Bencher) {
bench_nms(300, b);
}
#[bench]
fn nms_00500(b: &mut Bencher) {
bench_nms(500, b);
}
#[bench]
fn nms_01000(b: &mut Bencher) {
bench_nms(1000, b);
}
fn bench_nms(objects: usize, b: &mut Bencher) {
let pos_drift = 10.0;
let box_drift = 1.0;
let mut iterators = Vec::default();
for i in 0..objects {
iterators.push(BoxGen2::new(
i as f32, i as f32, 50.0, 50.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(), None));
}
nms(&observations, 0.8, None);
});
}