1
0
зеркало из https://github.com/glebtv/tui-textarea.git synced 2026-08-28 11:36:17 +03:00
Files
tui-textarea/bench/benches/delete_word.rs
srothgan 19151a4076 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
2026-02-19 09:22:09 +10:00

30 строки
865 B
Rust

use criterion::{criterion_group, criterion_main, Criterion};
use tui_textarea::{CursorMove, TextArea};
use tui_textarea_bench::{dummy_terminal, TerminalExt, LOREM};
#[inline]
fn run(textarea: &TextArea<'_>) {
let mut term = dummy_terminal();
let mut t = textarea.clone();
t.move_cursor(CursorMove::Jump(u16::MAX, u16::MAX));
for _ in 0..100 {
if !t.delete_word() {
t = textarea.clone();
t.move_cursor(CursorMove::Jump(u16::MAX, u16::MAX));
}
term.draw_textarea(&t);
}
}
fn bench(c: &mut Criterion) {
let mut lines = vec![];
for _ in 0..10 {
lines.extend(LOREM.iter().map(|s| s.to_string()));
}
let textarea = TextArea::new(lines);
c.bench_function("delete::word", |b| b.iter(|| run(&textarea)));
}
criterion_group!(delete_word, bench);
criterion_main!(delete_word);