-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (81 loc) · 3.3 KB
/
benchmark-example.yml
File metadata and controls
96 lines (81 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# Example workflow for external projects using git-bench
# Copy this file to your project's .github/workflows/ directory
#
# Prerequisites:
# 1. Your project must have benchmarks (cargo bench)
# 2. GitHub Pages must be enabled (Settings > Pages > Source: Deploy from a branch > gh-pages)
#
# Note on Rust toolchain:
# - libtest benchmarks (#![feature(test)]) require nightly Rust
# - Criterion benchmarks work on stable Rust
# This workflow uses nightly by default to support both.
#
# The workflow will:
# - Run your benchmarks on every push to main
# - Deploy results to GitHub Pages with an interactive dashboard
# - Compare with previous runs and alert on regressions
name: Benchmark
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: write
jobs:
benchmark:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Use nightly for libtest benchmarks (#![feature(test)])
# Change to @stable if only using Criterion
- uses: dtolnay/rust-toolchain@nightly
- name: Install git-bench
env:
# Pin to a specific version for reproducibility
# Check https://github.com/fedemagnani/git-bench/tags for available versions
GIT_BENCH_VERSION: "v0.0.1-alpha.10"
run: |
cargo install --git https://github.com/fedemagnani/git-bench --tag $GIT_BENCH_VERSION git-bench
# Build the dashboard (requires wasm target)
rustup target add wasm32-unknown-unknown
cargo install dioxus-cli
# Clone and build dashboard from the same version
git clone --depth 1 --branch $GIT_BENCH_VERSION https://github.com/fedemagnani/git-bench /tmp/git-bench
cd /tmp/git-bench/crates/dashboard && dx build --release
mkdir -p $GITHUB_WORKSPACE/dist
cp -r target/dx/git-bench-dashboard/release/web/public/* $GITHUB_WORKSPACE/dist/
# Fix paths for GitHub Pages subdirectory deployment
find $GITHUB_WORKSPACE/dist -type f \( -name "*.html" -o -name "*.js" \) -exec sed -i 's|"/\./|"./|g' {} \;
sed -i 's|<head>|<head><base href="./">|' $GITHUB_WORKSPACE/dist/index.html
- name: Run benchmarks
run: cargo bench 2>&1 | tee benchmark-output.txt
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Deploy results
if: github.ref == 'refs/heads/main'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git-bench run \
--output-file benchmark-output.txt \
--name "${{ github.event.repository.name }}" \
--github-token "$GITHUB_TOKEN" \
--auto-push \
--gh-pages-branch gh-pages \
--benchmark-data-dir-path dev/bench \
--dashboard-dir dist \
--alert-threshold "150%"
# Dashboard will be available at:
# https://<username>.github.io/<repo>/dev/bench/
- name: Upload benchmark output
uses: actions/upload-artifact@v4
if: always()
with:
name: benchmark-output
path: benchmark-output.txt
if-no-files-found: ignore