-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
benchmark.rs
40 lines (31 loc) · 863 Bytes
/
benchmark.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
#![feature(test)]
extern crate test;
use epaint::{pos2, Color32, Shape, Stroke};
use test::Bencher;
#[bench]
fn single_dashed_lines(b: &mut Bencher) {
b.iter(|| {
let mut v = Vec::new();
let line = [pos2(0.0, 0.0), pos2(50.0, 0.0), pos2(100.0, 1.0)];
for _ in 0..100 {
v.extend(Shape::dashed_line(
&line,
Stroke::new(1.5, Color32::RED),
10.0,
2.5,
));
}
test::black_box(v);
});
}
#[bench]
fn many_dashed_lines(b: &mut Bencher) {
b.iter(|| {
let mut v = Vec::new();
let line = [pos2(0.0, 0.0), pos2(50.0, 0.0), pos2(100.0, 1.0)];
for _ in 0..100 {
Shape::dashed_line_many(&line, Stroke::new(1.5, Color32::RED), 10.0, 2.5, &mut v);
}
test::black_box(v);
});
}