Skip to content

Commit d448fc3

Browse files
committed
Added: Add benchmark comparison tool and performance documentation
Introduce a Python script to compare Criterion results across baselines and generate markdown reports. Integrate performance snapshots into the release workflow and add justfile recipes for baseline management to track exact arithmetic performance. Refs: #63
1 parent 756917c commit d448fc3

5 files changed

Lines changed: 488 additions & 4 deletions

File tree

docs/PERFORMANCE.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Exact Arithmetic Performance
2+
3+
**la-stack** v0.3.0 · `0a8ce5b` (perf/63-custom-f64-to-bigrational) · 2026-04-10 23:57:42 UTC
4+
**Statistic**: median
5+
6+
## Benchmark Results
7+
8+
Current performance snapshot (no baseline comparison).
9+
10+
| Group | Benchmark | Median | 95% CI |
11+
|-------|-----------|-------:|-------:|
12+
| exact_d2 | det | 0.6 ns | [0.6 ns, 0.6 ns] |
13+
| exact_d2 | det_direct | 0.7 ns | [0.7 ns, 0.7 ns] |
14+
| exact_d2 | det_exact | 3.93 µs | [3.89 µs, 3.97 µs] |
15+
| exact_d2 | det_exact_f64 | 4.19 µs | [4.17 µs, 4.21 µs] |
16+
| exact_d2 | det_sign_exact | 1.1 ns | [1.1 ns, 1.1 ns] |
17+
| exact_d2 | solve_exact | 10.72 µs | [10.72 µs, 10.72 µs] |
18+
| exact_d2 | solve_exact_f64 | 11.22 µs | [11.19 µs, 11.25 µs] |
19+
| exact_d3 | det | 1.4 ns | [1.4 ns, 1.4 ns] |
20+
| exact_d3 | det_direct | 5.1 ns | [5.1 ns, 5.1 ns] |
21+
| exact_d3 | det_exact | 21.32 µs | [21.20 µs, 21.45 µs] |
22+
| exact_d3 | det_exact_f64 | 20.90 µs | [20.78 µs, 21.01 µs] |
23+
| exact_d3 | det_sign_exact | 3.3 ns | [3.2 ns, 3.3 ns] |
24+
| exact_d3 | solve_exact | 46.73 µs | [46.53 µs, 46.92 µs] |
25+
| exact_d3 | solve_exact_f64 | 51.25 µs | [50.61 µs, 51.90 µs] |
26+
| exact_d4 | det | 2.3 ns | [2.3 ns, 2.3 ns] |
27+
| exact_d4 | det_direct | 2.4 ns | [2.4 ns, 2.4 ns] |
28+
| exact_d4 | det_exact | 71.86 µs | [71.40 µs, 72.33 µs] |
29+
| exact_d4 | det_exact_f64 | 72.30 µs | [72.20 µs, 72.40 µs] |
30+
| exact_d4 | det_sign_exact | 6.3 ns | [6.3 ns, 6.3 ns] |
31+
| exact_d4 | solve_exact | 140.23 µs | [137.78 µs, 142.68 µs] |
32+
| exact_d4 | solve_exact_f64 | 144.25 µs | [142.93 µs, 145.58 µs] |
33+
| exact_d5 | det | 26.6 ns | [26.1 ns, 27.2 ns] |
34+
| exact_d5 | det_direct | 2.2 ns | [2.2 ns, 2.2 ns] |
35+
| exact_d5 | det_exact | 163.15 µs | [162.53 µs, 163.77 µs] |
36+
| exact_d5 | det_exact_f64 | 176.47 µs | [176.10 µs, 176.84 µs] |
37+
| exact_d5 | det_sign_exact | 176.38 µs | [173.58 µs, 179.18 µs] |
38+
| exact_d5 | solve_exact | 328.97 µs | [325.89 µs, 332.05 µs] |
39+
| exact_d5 | solve_exact_f64 | 333.97 µs | [333.03 µs, 334.91 µs] |
40+
| exact_near_singular_3x3 | det_sign_exact | 12.71 µs | [12.63 µs, 12.78 µs] |
41+
| exact_near_singular_3x3 | det_exact | 12.83 µs | [12.75 µs, 12.91 µs] |
42+
43+
## How to Update
44+
45+
```bash
46+
# Save a baseline at the current release
47+
just bench-save-baseline v0.3.0
48+
49+
# Compare current code against a saved baseline
50+
just bench-compare v0.3.0
51+
52+
# Generate a snapshot without comparison
53+
just bench-compare
54+
```
55+
56+
See `docs/RELEASING.md` for the full release workflow.

docs/RELEASING.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,20 @@ just plot-vs-linalg-readme
9191
Review the updated table in `README.md` and the plot in `docs/assets/` for
9292
accuracy.
9393

94-
5. Stage and commit release artifacts
94+
5. Save an exact-arithmetic benchmark baseline for this release
95+
96+
```bash
97+
# Run exact benchmarks and save a named Criterion baseline
98+
just bench-save-baseline $TAG
99+
100+
# Generate a performance snapshot in docs/PERFORMANCE.md
101+
just bench-compare
102+
```
103+
104+
This baseline can be compared against in future optimization work using
105+
`just bench-compare $TAG`. See `docs/PERFORMANCE.md` after generation.
106+
107+
6. Stage and commit release artifacts
95108

96109
```bash
97110
git add Cargo.toml Cargo.lock CHANGELOG.md README.md docs/
@@ -104,7 +117,7 @@ git commit -m "chore(release): release $TAG
104117
- Update documentation for release"
105118
```
106119

107-
6. Push the branch and open a PR
120+
7. Push the branch and open a PR
108121

109122
```bash
110123
git push -u origin "release/$TAG"

justfile

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,26 @@ bench:
9393
bench-compile:
9494
RUSTFLAGS='-D warnings' cargo bench --no-run --features bench
9595

96+
# Compare exact-arithmetic benchmarks against a saved baseline.
97+
# Omit the baseline arg to generate a snapshot without comparison.
98+
bench-compare baseline="": python-sync
99+
#!/usr/bin/env bash
100+
set -euo pipefail
101+
baseline="{{baseline}}"
102+
if [ -n "$baseline" ]; then
103+
uv run bench-compare "$baseline"
104+
else
105+
uv run bench-compare
106+
fi
107+
108+
# Run the exact-arithmetic benchmark suite.
109+
bench-exact:
110+
cargo bench --features bench,exact --bench exact
111+
112+
# Save a Criterion baseline for the exact-arithmetic benchmarks.
113+
bench-save-baseline tag:
114+
cargo bench --features bench,exact --bench exact -- --save-baseline {{tag}}
115+
96116
# Bench the la-stack vs nalgebra/faer comparison suite.
97117
bench-vs-linalg filter="":
98118
#!/usr/bin/env bash
@@ -342,7 +362,7 @@ python-sync: _ensure-uv
342362

343363
python-typecheck: python-sync
344364
uv run ty check scripts/
345-
uv run mypy scripts/criterion_dim_plot.py scripts/tag_release.py scripts/postprocess_changelog.py scripts/subprocess_utils.py
365+
uv run mypy scripts/bench_compare.py scripts/criterion_dim_plot.py scripts/tag_release.py scripts/postprocess_changelog.py scripts/subprocess_utils.py
346366

347367
# Setup
348368
setup: setup-tools

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,15 @@ dependencies = [ ]
3737
"Bug Tracker" = "https://github.com/acgetchell/la-stack/issues"
3838

3939
[project.scripts]
40+
bench-compare = "bench_compare:main"
4041
criterion-dim-plot = "criterion_dim_plot:main"
4142
postprocess-changelog = "postprocess_changelog:main"
4243
tag-release = "tag_release:main"
4344

4445
# Configure setuptools to find modules in scripts/ directory.
4546
[tool.setuptools]
4647
package-dir = { "" = "scripts" }
47-
py-modules = [ "criterion_dim_plot", "postprocess_changelog", "subprocess_utils", "tag_release" ]
48+
py-modules = [ "bench_compare", "criterion_dim_plot", "postprocess_changelog", "subprocess_utils", "tag_release" ]
4849

4950
[tool.ruff]
5051
line-length = 150

0 commit comments

Comments
 (0)