67 lines
1.7 KiB
YAML
67 lines
1.7 KiB
YAML
name: Performance Benchmarks
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
pull_request:
|
|
branches: [ main ]
|
|
workflow_dispatch:
|
|
inputs:
|
|
baseline:
|
|
description: 'Git ref to use as baseline (default: main)'
|
|
required: false
|
|
default: 'main'
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
jobs:
|
|
benchmark:
|
|
name: Run Benchmarks
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
|
|
- uses: Swatinem/rust-cache@v2
|
|
with:
|
|
cache-on-failure: true
|
|
|
|
- name: Install criterion helpers
|
|
run: cargo install critcmp || true
|
|
|
|
- name: Run benchmarks on current code
|
|
run: |
|
|
cargo bench --workspace -- --save-baseline current 2>/dev/null || \
|
|
cargo bench -p rtx-tensor -- --save-baseline current 2>/dev/null || \
|
|
echo "No benchmarks found or benchmark failed"
|
|
continue-on-error: true
|
|
|
|
- name: Checkout baseline (main)
|
|
if: gitea.event_name == 'pull_request'
|
|
run: |
|
|
git stash || true
|
|
git checkout ${{ gitea.base_ref || 'main' }}
|
|
|
|
- name: Run benchmarks on baseline
|
|
if: gitea.event_name == 'pull_request'
|
|
run: |
|
|
cargo bench --workspace -- --save-baseline baseline 2>/dev/null || true
|
|
continue-on-error: true
|
|
|
|
- name: Compare benchmarks
|
|
if: gitea.event_name == 'pull_request'
|
|
run: |
|
|
critcmp baseline current || echo "No comparison available"
|
|
continue-on-error: true
|
|
|
|
- name: Upload benchmark results
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: benchmark-results
|
|
path: target/criterion/
|
|
retention-days: 14
|