зеркало из
https://github.com/glebtv/tui-textarea.git
synced 2026-09-08 16:35:49 +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
Этот коммит содержится в:
37
bench/benches/search_backward.rs
Обычный файл
37
bench/benches/search_backward.rs
Обычный файл
@@ -0,0 +1,37 @@
|
||||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
use tui_textarea::TextArea;
|
||||
use tui_textarea_bench::{dummy_terminal, TerminalExt, LOREM};
|
||||
|
||||
#[inline]
|
||||
fn run(pat: &str, mut textarea: TextArea<'_>) {
|
||||
let mut term = dummy_terminal();
|
||||
textarea.set_search_pattern(pat).unwrap();
|
||||
term.draw_textarea(&textarea);
|
||||
for _ in 0..100 {
|
||||
textarea.search_back(false);
|
||||
term.draw_textarea(&textarea);
|
||||
}
|
||||
textarea.set_search_pattern(r"").unwrap();
|
||||
term.draw_textarea(&textarea);
|
||||
}
|
||||
|
||||
fn short(c: &mut Criterion) {
|
||||
let textarea = TextArea::from(LOREM.iter().map(|s| s.to_string()));
|
||||
c.bench_function("search::back_short", |b| {
|
||||
b.iter(|| run(r"\w*i\w*", textarea.clone()))
|
||||
});
|
||||
}
|
||||
|
||||
fn long(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("search::back_long", |b| {
|
||||
b.iter(|| run(r"[A-Z]\w*", textarea.clone()))
|
||||
});
|
||||
}
|
||||
|
||||
criterion_group!(search_backward, short, long);
|
||||
criterion_main!(search_backward);
|
||||
Ссылка в новой задаче
Block a user