1
0
зеркало из https://github.com/glebtv/tui-textarea.git synced 2026-09-08 00:15:50 +03:00

chore(bench): restructure into focused targets, add runner, and tune slow cases (#10)

- Upgrade Criterion 0.5 → 0.8.2
- Split 4 broad bench files into 14 focused targets
- Add Rust runner binary with per-target start/done logging
- Add wrap_render benchmarks (all 4 WrapMode variants × 2 sizes)
- Add undo_redo benchmarks (undo/redo × 3 history depths)
- Apply benchmark_group + SamplingMode::Flat + reduced sample_size on slow insert cases to cut total run time from ~28 min to ~12 min
- Rewrite bench/README.md to document runner, targets, and workflow
Этот коммит содержится в:
srothgan
2026-02-19 00:22:09 +01:00
коммит произвёл GitHub
родитель f03a7b9ec1
Коммит 19151a4076
20 изменённых файлов: 821 добавлений и 351 удалений

57
bench/benches/insert_append.rs Обычный файл
Просмотреть файл

@@ -0,0 +1,57 @@
use criterion::{criterion_group, criterion_main, Criterion, SamplingMode};
use tui_textarea::{Input, Key, TextArea};
use tui_textarea_bench::{dummy_terminal, TerminalExt, LOREM};
#[inline]
fn append_lorem(repeat: usize) -> usize {
let mut textarea = TextArea::default();
let mut term = dummy_terminal();
for _ in 0..repeat {
for line in LOREM {
for c in line.chars() {
textarea.input(Input {
key: Key::Char(c),
ctrl: false,
alt: false,
shift: false,
});
term.draw_textarea(&textarea);
}
}
textarea.input(Input {
key: Key::Enter,
ctrl: false,
alt: false,
shift: false,
});
term.draw_textarea(&textarea);
}
textarea.lines().len()
}
fn bench(c: &mut Criterion) {
let mut group = c.benchmark_group("insert::append");
// ~16ms/iter — fits 100 samples in ~6s, keep defaults
group.bench_function("1_lorem", |b| {
b.iter(|| std::hint::black_box(append_lorem(1)))
});
// ~490ms/iter — 20 samples × 490ms ≈ 10s
group.sampling_mode(SamplingMode::Flat);
group.sample_size(20);
group.bench_function("10_lorem", |b| {
b.iter(|| std::hint::black_box(append_lorem(10)))
});
// ~5.9s/iter — 10 samples × 5.9s ≈ 59s (minimum viable)
group.sample_size(10);
group.bench_function("50_lorem", |b| {
b.iter(|| std::hint::black_box(append_lorem(50)))
});
group.finish();
}
criterion_group!(insert_append, bench);
criterion_main!(insert_append);