Source: .github/workflows/benchmarks.yml · reusable workflow
Run cargo bench and write BENCHMARKS.md, only when asked.
Intended for: The build workflows' benchmarks job on tags with generate_benchmarks, and consumers' own workflow_dispatch callers (benchmark_template.yaml).
Release behavior#
One job on the runner it is given (ubuntu-24.04 by default): cargo bench, optionally with every feature and a filter passed to every bench target, then gen_benchmarks.py. BENCHMARKS.md goes to the run summary and an artifact, and to the release when release_name names one. The test jobs never run benchmarks, and no pull request waits for this.
Artifacts and effects#
- BENCHMARKS.md and benchmark-output.txt as a workflow artifact and in the run summary
- BENCHMARKS.md on the release, when release_name is set
Assumptions and permissions#
- The caller grants contents: write when it passes release_name; contents: read is enough otherwise.
- A hosted runner is shared hardware: compare numbers from the same runner label, and expect noise.
Failure modes#
- Benchmarks feature-gated behind features the defaults leave off do not run unless all_features is set.
- A harness = false bench decides for itself what the filter means.
Example#
Use the generated benchmark template.
Inputs#
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
all_features | boolean | false | false | Benchmark with every feature enabled (cargo bench --all-features), for benches gated behind features. |
filter | string | false | Passed to every bench target as cargo bench -- <filter>: Criterion runs the benchmarks whose ID contains it. Empty runs every benchmark. | |
os | string | false | ubuntu-24.04 | The runner to measure on, such as ubuntu-24.04, macos-latest, macos-26-intel or windows-2025-vs2026. |
release_name | string | false | Upload BENCHMARKS.md to this GitHub release; the caller grants contents: write. Empty keeps the results in the run: its summary and an artifact. |
Permissions#
Top-level: —. Undeclared means inherited from the caller, not "none needed".
Job dependency graph#
Edges are YAML needs; conditional jobs may not run. Conditions are listed below.
Read diagram source
flowchart TD
n_benchmarks["benchmarks"]
Jobs#
| Job | Needs | Runner / delegate | Container / strategy | Condition |
|---|---|---|---|---|
benchmarks | ${{ inputs.os }} / — | — / — | — |
Steps#
benchmarks#
| Step | Action / command | Condition |
|---|---|---|
| — | actions/checkout@v6 | — |
| — | actions/checkout@v6 | — |
| — | DreamWeave-MP/StroggForge/.github/actions/rust-setup@v72 | — |
| Run the benchmarks | rm -rf target/criterion benchmark-output.txt BENCHMARKS.md bash .stroggforge/scripts/shared/generate-benchmark-docs.sh .stroggforge/.github/scripts/gen_benchmarks.py cat BENCHMARKS.md >> "$GITHUB_STEP_SUMMARY" | — |
| — | actions/upload-artifact@v7 | always() |
| Upload BENCHMARKS.md to the release | gh release upload "$RELEASE_NAME" BENCHMARKS.md --clobber --repo "$REPOSITORY" | inputs.release_name != '' |