Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/release-bench.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Release benchmarks

# When a release is published, clone smartcore-benches into the runner and
# run its criterion + iai-callgrind harness against the released smartcore
# code (which is already checked out at the release commit SHA). A
# `[patch.crates-io]` override in a temporary `.cargo/config.toml` repoints
# the benches' `smartcore = "0.6"` dependency to the local checkout, so no
# crates.io round-trip or cross-repo dispatch is needed.
# See https://github.com/smartcorelib/smartcore/issues/407

on:
release:
types: [published]

jobs:
bench:
runs-on: ubuntu-latest
steps:
- name: Checkout smartcore (release commit)
uses: actions/checkout@v4

- name: Checkout smartcore-benches (sibling directory)
uses: actions/checkout@v4
with:
repository: smartcorelib/smartcore-benches
path: smartcore-benches

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Install Valgrind (for iai-callgrind)
run: sudo apt-get update && sudo apt-get install -y valgrind

- name: Cache .cargo and target
uses: actions/cache@v4
with:
path: |
~/.cargo
./smartcore-benches/target
key: release-bench-${{ hashFiles('Cargo.toml', 'smartcore-benches/Cargo.toml') }}
restore-keys: release-bench-

- name: Patch benches to use local smartcore
run: |
mkdir -p smartcore-benches/.cargo
cat > smartcore-benches/.cargo/config.toml <<'CFG'
[patch.crates-io]
smartcore = { path = "../" }
CFG

- name: Build benches (no-run)
working-directory: smartcore-benches
run: cargo bench --no-run

- name: Run criterion benchmarks
working-directory: smartcore-benches
run: |
mkdir -p bench-output
cargo bench -- --output-format bencher | tee bench-output/criterion.json

- name: Run iai-callgrind benchmarks
working-directory: smartcore-benches
run: |
for bench in iai_matmul iai_ab iai_svd iai_cover_tree iai_iterator_mut; do
cargo bench --bench "$bench" -- --save-baseline=release 2>&1 | tee "bench-output/${bench}.json" || true
done

- name: Upload benchmark results
uses: actions/upload-artifact@v4
with:
name: release-benchmark-results
path: smartcore-benches/bench-output/
retention-days: 90
Loading