Benchmarks

.github/workflows/benchmarks.yml

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#

NameTypeRequiredDefaultDescription
all_featuresbooleanfalsefalseBenchmark with every feature enabled (cargo bench --all-features), for benches gated behind features.
filterstringfalsePassed to every bench target as cargo bench -- <filter>: Criterion runs the benchmarks whose ID contains it. Empty runs every benchmark.
osstringfalseubuntu-24.04The runner to measure on, such as ubuntu-24.04, macos-latest, macos-26-intel or windows-2025-vs2026.
release_namestringfalseUpload 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.

workflow-benchmarks relationship diagram. Its textual ledger or workflow contract is on this page or linked below.
workflow benchmarks · Mermaid source · Full-size SVG
Read diagram source
flowchart TD
  n_benchmarks["benchmarks"]

Jobs#

JobNeedsRunner / delegateContainer / strategyCondition
benchmarks${{ inputs.os }} / —— / ——

Steps#

benchmarks#

StepAction / commandCondition
—actions/checkout@v6—
—actions/checkout@v6—
—DreamWeave-MP/StroggForge/.github/actions/rust-setup@v72—
Run the benchmarksrm -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@v7always()
Upload BENCHMARKS.md to the releasegh release upload "$RELEASE_NAME" BENCHMARKS.md --clobber --repo "$REPOSITORY"inputs.release_name != ''