зеркало из
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
Этот коммит содержится в:
@@ -1,34 +1,74 @@
|
||||
Benchmarks for tui-textarea using [Criterion.rs][criterion].
|
||||
|
||||
To run all benchmarks:
|
||||
## Running all benchmarks (Rust runner — recommended)
|
||||
|
||||
The Rust runner executes every benchmark target sequentially and prints
|
||||
per-target start time, exit status, and wall duration.
|
||||
|
||||
```sh
|
||||
cargo bench --benches
|
||||
cargo run -p tui-textarea-bench --bin runner
|
||||
```
|
||||
|
||||
To run specific benchmark suite:
|
||||
Example output:
|
||||
|
||||
```
|
||||
[1/12] START insert_append at 2026-02-18T12:00:00Z
|
||||
[1/12] DONE insert_append status=ok duration=42.31s
|
||||
[2/12] START insert_random at 2026-02-18T12:00:42Z
|
||||
...
|
||||
All 14 benchmark targets completed successfully.
|
||||
```
|
||||
|
||||
## Running a single benchmark target
|
||||
|
||||
```sh
|
||||
cargo bench --bench insert
|
||||
cargo bench -p tui-textarea-bench --bench insert_append
|
||||
```
|
||||
|
||||
To filter benchmarks:
|
||||
Available targets:
|
||||
|
||||
| Target | What it measures |
|
||||
|--------------------|-------------------------------------------|
|
||||
| `insert_append` | Appending lorem lines sequentially |
|
||||
| `insert_random` | Inserting lorem lines at random positions |
|
||||
| `insert_long` | Typing a long line without newlines |
|
||||
| `search_forward` | Forward regex search |
|
||||
| `search_backward` | Backward regex search |
|
||||
| `cursor_char` | Character-level cursor movement |
|
||||
| `cursor_word` | Word-level cursor movement |
|
||||
| `cursor_paragraph` | Paragraph-level cursor movement |
|
||||
| `cursor_edge` | Head/end and top/bottom jumps |
|
||||
| `delete_char` | Deleting one character at a time |
|
||||
| `delete_word` | Deleting one word at a time |
|
||||
| `delete_line` | Deleting to line head |
|
||||
| `wrap_render` | Rendering with Word/Glyph/WordOrGlyph wrap modes |
|
||||
| `undo_redo` | Undo and redo traversal at varying history depths |
|
||||
|
||||
## Filtering within a target
|
||||
|
||||
Pass a filter string after `--` to run only matching cases:
|
||||
|
||||
```sh
|
||||
cargo bench append::1_lorem
|
||||
cargo bench -p tui-textarea-bench --bench insert_append -- append::10_lorem
|
||||
```
|
||||
|
||||
To compare benchmark results with [critcmp][]:
|
||||
## Comparing branches with [critcmp][]
|
||||
|
||||
```sh
|
||||
git checkout main
|
||||
cargo bench -- --save-baseline base
|
||||
cargo bench -p tui-textarea-bench -- --save-baseline base
|
||||
|
||||
git checkout your-feature
|
||||
cargo bench -- --save-baseline change
|
||||
cargo bench -p tui-textarea-bench -- --save-baseline change
|
||||
|
||||
critcmp base change
|
||||
```
|
||||
|
||||
## Note on `cargo test -p tui-textarea-bench`
|
||||
|
||||
Running `cargo test` on this package is a smoke test only — it verifies
|
||||
that the benchmark code compiles and runs without panicking, but produces
|
||||
no timing data. Use `cargo bench` or the Rust runner for real measurements.
|
||||
|
||||
[criterion]: https://github.com/bheisler/criterion.rs
|
||||
[critcmp]: https://github.com/BurntSushi/critcmp
|
||||
|
||||
Ссылка в новой задаче
Block a user