1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-26 22:53:14 -04:00

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:
Lucas Meurer
2025-04-30 10:38:41 +02:00
committed by GitHub
parent c075053391
commit 1ab3259008

View File

@@ -4,7 +4,7 @@ use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
use egui::epaint::TextShape;
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 rand::Rng as _;
@@ -121,6 +121,15 @@ pub fn criterion_benchmark(c: &mut Criterion) {
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,
);
});
});
}