Benchmark Baseline workflow (clap-rs/clap)
The Benchmark Baseline workflow from clap-rs/clap, explained and optimized by Latchkey.
CI health: C - fair
Run this on Latchkey for self-healing, caching, and up to 58% lower cost.
Grade your own workflow free or run it on Latchkey →What it does
This is the Benchmark Baseline workflow from the clap-rs/clap repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: Benchmark Baseline
permissions:
contents: read
on:
push:
branches: master
jobs:
bench:
name: Binary Size
permissions:
checks: write
strategy:
matrix:
build: [linux]
include:
- build: linux
os: ubuntu-latest
runs-on: "${{ matrix.os }}"
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Install Bencher
uses: bencherdev/bencher@main
- name: Build
run: "cargo build --package clap --example git-derive -F derive --release"
env:
CARGO_PROFILE_RELEASE_STRIP: true
- name: Report
run: |
bencher run \
--project $(echo "${{ github.repository }}" | sed 's/\//-/g') \
--branch "${{ github.ref_name }}" \
--testbed "${{ matrix.os }}" \
--token '${{ secrets.BENCHER_API_TOKEN }}' \
--github-actions '${{ secrets.GITHUB_TOKEN }}' \
--adapter json \
--file-size target/release/examples/git-derive
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Benchmark Baseline permissions: contents: read on: push: branches: master concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: bench: timeout-minutes: 30 name: Binary Size permissions: checks: write strategy: matrix: build: [linux] include: - build: linux os: ubuntu-latest runs-on: "${{ matrix.os }}" steps: - name: Checkout repository uses: actions/checkout@v7 - name: Install Rust uses: dtolnay/rust-toolchain@stable with: toolchain: stable - uses: Swatinem/rust-cache@v2 - name: Install Bencher uses: bencherdev/bencher@main - name: Build run: "cargo build --package clap --example git-derive -F derive --release" env: CARGO_PROFILE_RELEASE_STRIP: true - name: Report run: | bencher run \ --project $(echo "${{ github.repository }}" | sed 's/\//-/g') \ --branch "${{ github.ref_name }}" \ --testbed "${{ matrix.os }}" \ --token '${{ secrets.BENCHER_API_TOKEN }}' \ --github-actions '${{ secrets.GITHUB_TOKEN }}' \ --adapter json \ --file-size target/release/examples/git-derive
What changed
- Cancel superseded runs when a branch or PR gets a newer push.
- Add a job timeout so a hung step cannot burn hours of runner time.
3 third-party actions are referenced by a movable tag. Pin them to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.
What Latchkey heals here
This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:
- Dependency installs
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.