name: Benchmark Gate
on:
pull_request:
branches: [main]
paths:
- src/**/*.rs
- Cargo.toml
- Cargo.lock
- benches/**/*.rs
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -D warnings
jobs:
bench:
runs-on: self-hosted
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Cache cargo registry
uses: actions/cache@v6
with:
path: |
~/.cargo/registry
~/.cargo/git
key: bench-cargo-registry-${{ hashFiles('Cargo.lock') }}
restore-keys: bench-cargo-registry-
- name: Install cargo-criterion
uses: baptiste0928/cargo-install@v3
with:
crate: cargo-criterion
- name: Build bench deps
run: cargo build --benches --locked
- name: Run benchmarks
run: cargo criterion --message-format=json 2>&1 | tee bench-output.json
- uses: benchmark-action/github-action-benchmark@v1
with:
tool: cargo
output-file-path: bench-output.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: false
alert-threshold: "200%"
comment-on-alert: true
summary-always: true