mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 14:50:03 -04:00
Split out the Egui demo code to new crate egui_demo_lib
This commit is contained in:
61
egui_demo_lib/benches/benchmark.rs
Normal file
61
egui_demo_lib/benches/benchmark.rs
Normal file
@@ -0,0 +1,61 @@
|
||||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
|
||||
pub fn criterion_benchmark(c: &mut Criterion) {
|
||||
let raw_input = egui::RawInput::default();
|
||||
|
||||
{
|
||||
let mut ctx = egui::CtxRef::default();
|
||||
let mut demo_windows = egui_demo_lib::DemoWindows::default();
|
||||
|
||||
c.bench_function("demo_windows_minimal", |b| {
|
||||
b.iter(|| {
|
||||
ctx.begin_frame(raw_input.clone());
|
||||
demo_windows.ui(&ctx, &Default::default(), &mut None, |_ui| {});
|
||||
ctx.end_frame()
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
let mut ctx = egui::CtxRef::default();
|
||||
ctx.memory().all_collpasing_are_open = true; // expand the demo window with everything
|
||||
let mut demo_windows = egui_demo_lib::DemoWindows::default();
|
||||
|
||||
c.bench_function("demo_windows_full", |b| {
|
||||
b.iter(|| {
|
||||
ctx.begin_frame(raw_input.clone());
|
||||
demo_windows.ui(&ctx, &Default::default(), &mut None, |_ui| {});
|
||||
ctx.end_frame()
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
let mut ctx = egui::CtxRef::default();
|
||||
ctx.memory().all_collpasing_are_open = true; // expand the demo window with everything
|
||||
let mut demo_windows = egui_demo_lib::DemoWindows::default();
|
||||
ctx.begin_frame(raw_input.clone());
|
||||
demo_windows.ui(&ctx, &Default::default(), &mut None, |_ui| {});
|
||||
let (_, paint_commands) = ctx.end_frame();
|
||||
|
||||
c.bench_function("tessellate", |b| {
|
||||
b.iter(|| ctx.tessellate(paint_commands.clone()))
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
let mut ctx = egui::CtxRef::default();
|
||||
ctx.begin_frame(raw_input);
|
||||
egui::CentralPanel::default().show(&ctx, |ui| {
|
||||
c.bench_function("label", |b| {
|
||||
b.iter(|| {
|
||||
ui.label(egui_demo_lib::LOREM_IPSUM_LONG);
|
||||
})
|
||||
});
|
||||
});
|
||||
let _ = ctx.end_frame();
|
||||
}
|
||||
}
|
||||
|
||||
criterion_group!(benches, criterion_benchmark);
|
||||
criterion_main!(benches);
|
||||
Reference in New Issue
Block a user