2020-05-20 19:20:39 +00:00
|
|
|
use criterion::{criterion_group, criterion_main, Criterion};
|
|
|
|
|
|
|
|
pub fn criterion_benchmark(c: &mut Criterion) {
|
2020-05-30 08:22:35 +00:00
|
|
|
let raw_input = egui::RawInput {
|
|
|
|
screen_size: egui::vec2(1280.0, 1024.0),
|
2020-05-20 19:20:39 +00:00
|
|
|
..Default::default()
|
|
|
|
};
|
|
|
|
|
2020-09-09 10:41:59 +00:00
|
|
|
{
|
|
|
|
let mut ctx = egui::Context::new();
|
2020-10-19 21:06:11 +00:00
|
|
|
let mut demo_windows = egui::demos::DemoWindows::default();
|
2020-09-09 10:41:59 +00:00
|
|
|
|
2020-10-19 21:06:11 +00:00
|
|
|
c.bench_function("demo_windows_minimal", |b| {
|
2020-10-10 04:57:56 +00:00
|
|
|
b.iter(|| {
|
2020-10-24 08:56:23 +00:00
|
|
|
ctx.begin_frame(raw_input.clone());
|
2020-10-24 17:23:16 +00:00
|
|
|
demo_windows.ui(&ctx, &Default::default(), &mut None);
|
2020-10-10 04:57:56 +00:00
|
|
|
ctx.end_frame()
|
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
let mut ctx = egui::Context::new();
|
|
|
|
ctx.memory().all_collpasing_are_open = true; // expand the demo window with everything
|
2020-10-19 21:06:11 +00:00
|
|
|
let mut demo_windows = egui::demos::DemoWindows::default();
|
2020-10-10 04:57:56 +00:00
|
|
|
|
2020-10-19 21:06:11 +00:00
|
|
|
c.bench_function("demo_windows_full", |b| {
|
2020-09-09 10:41:59 +00:00
|
|
|
b.iter(|| {
|
2020-10-24 08:56:23 +00:00
|
|
|
ctx.begin_frame(raw_input.clone());
|
2020-10-24 17:23:16 +00:00
|
|
|
demo_windows.ui(&ctx, &Default::default(), &mut None);
|
2020-09-09 10:41:59 +00:00
|
|
|
ctx.end_frame()
|
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
let mut ctx = egui::Context::new();
|
2020-10-24 08:56:23 +00:00
|
|
|
ctx.begin_frame(raw_input);
|
2020-10-24 16:37:20 +00:00
|
|
|
egui::CentralPanel::default().show(&ctx, |ui| {
|
|
|
|
c.bench_function("label", |b| {
|
|
|
|
b.iter(|| {
|
|
|
|
ui.label(egui::demos::LOREM_IPSUM_LONG);
|
|
|
|
})
|
|
|
|
});
|
2020-09-09 10:41:59 +00:00
|
|
|
});
|
|
|
|
// let _ = ctx.end_frame(); // skip, because tessellating all that text is slow
|
|
|
|
}
|
2020-05-20 19:20:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
criterion_group!(benches, criterion_benchmark);
|
|
|
|
criterion_main!(benches);
|