зеркало из
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
Этот коммит содержится в:
50
bench/benches/cursor_char.rs
Обычный файл
50
bench/benches/cursor_char.rs
Обычный файл
@@ -0,0 +1,50 @@
|
||||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
use tui_textarea::CursorMove;
|
||||
use tui_textarea_bench::{prepare_cursor_textarea, run_cursor, Restore};
|
||||
|
||||
fn bench(c: &mut Criterion) {
|
||||
let textarea = prepare_cursor_textarea();
|
||||
c.bench_function("cursor::char::forward", |b| {
|
||||
b.iter(|| {
|
||||
std::hint::black_box(run_cursor(
|
||||
textarea.clone(),
|
||||
&[CursorMove::Forward],
|
||||
Restore::TopLeft,
|
||||
1000,
|
||||
))
|
||||
})
|
||||
});
|
||||
c.bench_function("cursor::char::back", |b| {
|
||||
b.iter(|| {
|
||||
std::hint::black_box(run_cursor(
|
||||
textarea.clone(),
|
||||
&[CursorMove::Back],
|
||||
Restore::BottomRight,
|
||||
1000,
|
||||
))
|
||||
})
|
||||
});
|
||||
c.bench_function("cursor::char::down", |b| {
|
||||
b.iter(|| {
|
||||
std::hint::black_box(run_cursor(
|
||||
textarea.clone(),
|
||||
&[CursorMove::Down],
|
||||
Restore::TopLeft,
|
||||
1000,
|
||||
))
|
||||
})
|
||||
});
|
||||
c.bench_function("cursor::char::up", |b| {
|
||||
b.iter(|| {
|
||||
std::hint::black_box(run_cursor(
|
||||
textarea.clone(),
|
||||
&[CursorMove::Up],
|
||||
Restore::BottomLeft,
|
||||
1000,
|
||||
))
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
criterion_group!(cursor_char, bench);
|
||||
criterion_main!(cursor_char);
|
||||
Ссылка в новой задаче
Block a user