Add italic button benchmark to test `RichText` performance impact (#6897)
Time on my m4 pro macbook: 302.79 ns (vs 303.83 ns for the regular
button 🤷)
This commit is contained in:
parent
c075053391
commit
1ab3259008
|
|
@ -4,7 +4,7 @@ use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
|
||||||
|
|
||||||
use egui::epaint::TextShape;
|
use egui::epaint::TextShape;
|
||||||
use egui::load::SizedTexture;
|
use egui::load::SizedTexture;
|
||||||
use egui::{Button, Id, TextureId, Ui, UiBuilder, Vec2};
|
use egui::{Button, Id, RichText, TextureId, Ui, UiBuilder, Vec2};
|
||||||
use egui_demo_lib::LOREM_IPSUM_LONG;
|
use egui_demo_lib::LOREM_IPSUM_LONG;
|
||||||
use rand::Rng as _;
|
use rand::Rng as _;
|
||||||
|
|
||||||
|
|
@ -121,6 +121,15 @@ pub fn criterion_benchmark(c: &mut Criterion) {
|
||||||
BatchSize::LargeInput,
|
BatchSize::LargeInput,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
group.bench_function("4_button_italic", |b| {
|
||||||
|
b.iter_batched_ref(
|
||||||
|
|| create_benchmark_ui(ctx),
|
||||||
|
|ui| {
|
||||||
|
ui.add(Button::new(RichText::new("Hello World").italics()));
|
||||||
|
},
|
||||||
|
BatchSize::LargeInput,
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue