2020-05-20 19:20:39 +00:00
|
|
|
use criterion::{criterion_group, criterion_main, Criterion};
|
|
|
|
|
|
|
|
pub fn criterion_benchmark(c: &mut Criterion) {
|
2020-12-16 20:48:02 +00:00
|
|
|
let raw_input = egui::RawInput::default();
|
2020-05-20 19:20:39 +00:00
|
|
|
|
2020-09-09 10:41:59 +00:00
|
|
|
{
|
2020-12-19 13:48:04 +00:00
|
|
|
let mut ctx = egui::CtxRef::default();
|
2020-12-29 12:40:11 +00:00
|
|
|
let mut demo_windows = egui_demo_lib::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());
|
2021-01-02 00:01:01 +00:00
|
|
|
demo_windows.ui(&ctx);
|
2020-10-10 04:57:56 +00:00
|
|
|
ctx.end_frame()
|
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2020-12-19 13:48:04 +00:00
|
|
|
let mut ctx = egui::CtxRef::default();
|
2021-01-02 13:42:43 +00:00
|
|
|
ctx.memory().set_everything_is_visible(true); // give us everything
|
2020-12-29 12:40:11 +00:00
|
|
|
let mut demo_windows = egui_demo_lib::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());
|
2021-01-02 00:01:01 +00:00
|
|
|
demo_windows.ui(&ctx);
|
2020-09-09 10:41:59 +00:00
|
|
|
ctx.end_frame()
|
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-11-07 10:44:32 +00:00
|
|
|
{
|
2020-12-19 13:48:04 +00:00
|
|
|
let mut ctx = egui::CtxRef::default();
|
2021-01-02 13:42:43 +00:00
|
|
|
ctx.memory().set_everything_is_visible(true); // give us everything
|
2020-12-29 12:40:11 +00:00
|
|
|
let mut demo_windows = egui_demo_lib::DemoWindows::default();
|
2020-11-07 10:44:32 +00:00
|
|
|
ctx.begin_frame(raw_input.clone());
|
2021-01-02 00:01:01 +00:00
|
|
|
demo_windows.ui(&ctx);
|
2020-11-07 10:44:32 +00:00
|
|
|
let (_, paint_commands) = ctx.end_frame();
|
|
|
|
|
2020-12-28 23:51:27 +00:00
|
|
|
c.bench_function("tessellate", |b| {
|
|
|
|
b.iter(|| ctx.tessellate(paint_commands.clone()))
|
2020-11-07 10:44:32 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-09-09 10:41:59 +00:00
|
|
|
{
|
2020-12-19 13:48:04 +00:00
|
|
|
let mut ctx = egui::CtxRef::default();
|
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(|| {
|
2020-12-29 12:40:11 +00:00
|
|
|
ui.label(egui_demo_lib::LOREM_IPSUM_LONG);
|
2020-10-24 16:37:20 +00:00
|
|
|
})
|
|
|
|
});
|
2020-09-09 10:41:59 +00:00
|
|
|
});
|
2020-11-07 10:44:32 +00:00
|
|
|
let _ = ctx.end_frame();
|
2020-09-09 10:41:59 +00:00
|
|
|
}
|
2020-05-20 19:20:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
criterion_group!(benches, criterion_benchmark);
|
|
|
|
criterion_main!(benches);
|