mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 23:00:04 -04:00
egui and eframe now uses more ViewportIdPair
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
|
||||
use egui::{epaint::TextShape, ViewportId};
|
||||
use egui::{epaint::TextShape, ViewportIdPair};
|
||||
use egui_demo_lib::LOREM_IPSUM_LONG;
|
||||
|
||||
pub fn criterion_benchmark(c: &mut Criterion) {
|
||||
@@ -13,39 +13,24 @@ pub fn criterion_benchmark(c: &mut Criterion) {
|
||||
// The most end-to-end benchmark.
|
||||
c.bench_function("demo_with_tessellate__realistic", |b| {
|
||||
b.iter(|| {
|
||||
let full_output = ctx.run(
|
||||
RawInput::default(),
|
||||
ViewportId::MAIN,
|
||||
ViewportId::MAIN,
|
||||
|ctx| {
|
||||
demo_windows.ui(ctx);
|
||||
},
|
||||
);
|
||||
let full_output = ctx.run(RawInput::default(), ViewportIdPair::MAIN, |ctx| {
|
||||
demo_windows.ui(ctx);
|
||||
});
|
||||
ctx.tessellate(full_output.shapes)
|
||||
});
|
||||
});
|
||||
|
||||
c.bench_function("demo_no_tessellate", |b| {
|
||||
b.iter(|| {
|
||||
ctx.run(
|
||||
RawInput::default(),
|
||||
ViewportId::MAIN,
|
||||
ViewportId::MAIN,
|
||||
|ctx| {
|
||||
demo_windows.ui(ctx);
|
||||
},
|
||||
)
|
||||
ctx.run(RawInput::default(), ViewportIdPair::MAIN, |ctx| {
|
||||
demo_windows.ui(ctx);
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
let full_output = ctx.run(
|
||||
RawInput::default(),
|
||||
ViewportId::MAIN,
|
||||
ViewportId::MAIN,
|
||||
|ctx| {
|
||||
demo_windows.ui(ctx);
|
||||
},
|
||||
);
|
||||
let full_output = ctx.run(RawInput::default(), ViewportIdPair::MAIN, |ctx| {
|
||||
demo_windows.ui(ctx);
|
||||
});
|
||||
c.bench_function("demo_only_tessellate", |b| {
|
||||
b.iter(|| ctx.tessellate(full_output.shapes.clone()));
|
||||
});
|
||||
@@ -57,44 +42,34 @@ pub fn criterion_benchmark(c: &mut Criterion) {
|
||||
let mut demo_windows = egui_demo_lib::DemoWindows::default();
|
||||
c.bench_function("demo_full_no_tessellate", |b| {
|
||||
b.iter(|| {
|
||||
ctx.run(
|
||||
RawInput::default(),
|
||||
ViewportId::MAIN,
|
||||
ViewportId::MAIN,
|
||||
|ctx| {
|
||||
demo_windows.ui(ctx);
|
||||
},
|
||||
)
|
||||
ctx.run(RawInput::default(), ViewportIdPair::MAIN, |ctx| {
|
||||
demo_windows.ui(ctx);
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
let ctx = egui::Context::default();
|
||||
let _ = ctx.run(
|
||||
RawInput::default(),
|
||||
ViewportId::MAIN,
|
||||
ViewportId::MAIN,
|
||||
|ctx| {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
c.bench_function("label &str", |b| {
|
||||
b.iter(|| {
|
||||
ui.label("the quick brown fox jumps over the lazy dog");
|
||||
});
|
||||
});
|
||||
c.bench_function("label format!", |b| {
|
||||
b.iter(|| {
|
||||
ui.label("the quick brown fox jumps over the lazy dog".to_owned());
|
||||
});
|
||||
let _ = ctx.run(RawInput::default(), ViewportIdPair::MAIN, |ctx| {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
c.bench_function("label &str", |b| {
|
||||
b.iter(|| {
|
||||
ui.label("the quick brown fox jumps over the lazy dog");
|
||||
});
|
||||
});
|
||||
},
|
||||
);
|
||||
c.bench_function("label format!", |b| {
|
||||
b.iter(|| {
|
||||
ui.label("the quick brown fox jumps over the lazy dog".to_owned());
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
let ctx = egui::Context::default();
|
||||
ctx.begin_frame(RawInput::default(), ViewportId::MAIN, ViewportId::MAIN);
|
||||
ctx.begin_frame(RawInput::default(), ViewportIdPair::MAIN);
|
||||
|
||||
egui::CentralPanel::default().show(&ctx, |ui| {
|
||||
c.bench_function("Painter::rect", |b| {
|
||||
|
||||
Reference in New Issue
Block a user