mirror of https://github.com/emilk/egui.git
Lampsitter
3 years ago
committed by
GitHub
5 changed files with 71 additions and 7 deletions
@ -0,0 +1,43 @@ |
|||
use criterion::{black_box, criterion_group, criterion_main, Criterion}; |
|||
|
|||
use epaint::{pos2, Color32, Shape, Stroke}; |
|||
|
|||
fn single_dashed_lines(c: &mut Criterion) { |
|||
c.bench_function("single_dashed_lines", move |b| { |
|||
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, |
|||
)); |
|||
} |
|||
|
|||
black_box(v); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
fn many_dashed_lines(c: &mut Criterion) { |
|||
c.bench_function("many_dashed_lines", move |b| { |
|||
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); |
|||
} |
|||
|
|||
black_box(v); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
criterion_group!(benches, single_dashed_lines, many_dashed_lines); |
|||
criterion_main!(benches); |
Loading…
Reference in new issue