Extend and improve ucd benchmark

This commit is contained in:
Leonard Hecker 2025-03-28 22:53:32 +01:00
parent ed78bc917f
commit 1e6da2e93d

View file

@ -4,7 +4,12 @@ use edit::ucd::MeasurementConfig;
use std::hint::black_box;
fn bench(c: &mut Criterion) {
let reference = "The quick brown fox jumps over the lazy dog\u{1F469}\u{1F3FB}\u{200D}\u{2764}\u{FE0F}\u{200D}\u{1F48B}\u{200D}\u{1F468}\u{1F3FB}\n";
let reference = concat!(
"In the quiet twilight, dreams unfold, soft whispers of a story untold.\n",
"月明かりが静かに照らし出し、夢を見る心の奥で詩が静かに囁かれる\n",
"Stars collide in the early light of hope, echoing the silent call of the night.\n",
"夜の静寂、希望と孤独が混ざり合うその中で詩が永遠に続く\n",
);
let buffer = reference.repeat(10);
let bytes = buffer.as_bytes();
@ -13,6 +18,15 @@ fn bench(c: &mut Criterion) {
group.bench_function("MeasurementConfig::goto_logical", |b| {
b.iter(|| black_box(MeasurementConfig::new(&bytes).goto_logical(Point::MAX)))
});
group.bench_function("MeasurementConfig::goto_logical with word wrap", |b| {
b.iter(|| {
black_box(
MeasurementConfig::new(&bytes)
.with_word_wrap_column(50)
.goto_logical(Point::MAX),
)
})
});
group.finish();
}