diff --git a/docs/testing.md b/docs/testing.md index c49be2b71..f41cbd286 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -49,3 +49,36 @@ OX_LIVE_CONFIG=/path/to/config.toml cargo test -p ox-core --test live -- --ignor - `OX_LIVE_CONFIG` (required): path to the TOML configuration file defining providers and models. - `OX_LIVE_MODEL` (optional): model alias to test, overriding `default_model` in the config file. + +## Benchmarks + +Criterion microbenchmarks measure latency and throughput on core parsing and TUI rendering hot paths across two workspace targets: + +| Crate | Target | Group | Covered hot paths | +| --------- | ----------- | --------------------- | ------------------------------------------------------------------------------------ | +| `ox-core` | `hot_paths` | `ox_core/compaction` | Fair budget allocation, UTF-8 truncation, compaction cut points, and file extraction | +| `ox-core` | `hot_paths` | `ox_core/catalog` | Built-in `ModelCatalog` load and custom TOML catalog parsing | +| `ox-core` | `hot_paths` | `ox_core/sse` | Chunked OpenAI Responses and Anthropic Messages SSE stream parsing | +| `ox-core` | `hot_paths` | `ox_core/frontmatter` | Skill Markdown frontmatter parsing | +| `ox-tui` | `render` | `ox_tui/markdown` | Multi-block `render_markdown` and warm-cache `render_markdown_incremental` | +| `ox-tui` | `render` | `ox_tui/ui` | Populated transcript frame draw (`render`) on a 120x40 `TestBackend` | +| `ox-tui` | `render` | `ox_tui/svg` | 120x40 terminal buffer conversion via `render_buffer_to_svg` | + +Common local commands: + +```bash +# Compile-check all benchmark targets without running them +cargo bench --no-run + +# Smoke-test every benchmark once without statistical sampling +cargo bench --bench hot_paths --bench render -- --test + +# Run the full Criterion benchmark suite +cargo bench --bench hot_paths --bench render + +# Compare before / after a change with named baselines +cargo bench --bench hot_paths --bench render -- --save-baseline before +cargo bench --bench hot_paths --bench render -- --baseline before +``` + +In CI, `.github/workflows/benchmarks.yml` compile-checks both targets on pull requests that touch `Cargo.toml`, `Cargo.lock`, `crates/*/Cargo.toml`, `crates/*/benches/**`, or the workflow file itself, and runs the full suite on a weekly Monday 03:00 UTC schedule or via `workflow_dispatch`.