Skip to content

Commit

Permalink
Add dashed_line benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
lampsitter committed Jan 4, 2022
1 parent fce3083 commit 8824e18
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions epaint/benches/benchmark.rs
@@ -0,0 +1,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);
});
}

0 comments on commit 8824e18

Please sign in to comment.