Skip to content

Commit a4a5f75

Browse files
authored
ci(bench): track benchmark numbers on main via benchmark-action (#412)
Add a new workflow that runs the benchmark suite on every push to main, stores the raw output and a generated HTML dashboard in an orphan `benchmarks` branch via benchmark-action/github-action-benchmark, and comments on any commit whose numbers are >=150% slower than the recorded best. Data stays off gh-pages so the MkDocs documentation deploy is not disturbed.
1 parent 46fe5d5 commit a4a5f75

1 file changed

Lines changed: 63 additions & 0 deletions

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Benchmark history
2+
3+
# Track benchmark numbers over time on main. Data (and an auto-generated
4+
# HTML dashboard) is pushed to the orphan `benchmarks` branch on every
5+
# push so regressions are visible commit-by-commit without touching the
6+
# MkDocs docs site.
7+
on:
8+
push:
9+
branches: [main]
10+
paths:
11+
- '**/*.go'
12+
- 'go.mod'
13+
- 'go.sum'
14+
- '.github/workflows/bench-history.yml'
15+
workflow_dispatch:
16+
17+
permissions:
18+
# Needed to push benchmark results back to the `benchmarks` branch.
19+
contents: write
20+
21+
concurrency:
22+
group: bench-history
23+
cancel-in-progress: false
24+
25+
jobs:
26+
bench:
27+
name: Record main benchmarks
28+
runs-on: ubuntu-latest
29+
timeout-minutes: 20
30+
steps:
31+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.0
32+
with:
33+
fetch-depth: 0
34+
35+
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.0.0
36+
with:
37+
go-version: '1.25.0'
38+
39+
- name: Run benchmarks
40+
run: |
41+
mkdir -p bench-output
42+
go test ./... -run='^$' -bench=. -benchmem -count=6 \
43+
| tee bench-output/bench.txt
44+
45+
- name: Publish to benchmarks branch
46+
uses: benchmark-action/github-action-benchmark@a60cea5bc7b49e15c1f58f411161f99e0df48372 # v1
47+
with:
48+
tool: 'go'
49+
output-file-path: bench-output/bench.txt
50+
github-token: ${{ secrets.GITHUB_TOKEN }}
51+
# Keep the data and dashboard off gh-pages so the MkDocs site
52+
# is not disturbed. The `benchmarks` branch is an orphan that
53+
# the action manages end-to-end.
54+
gh-pages-branch: benchmarks
55+
benchmark-data-dir-path: dev/bench
56+
auto-push: true
57+
# 150% = 1.5x slower than the recorded best — generous enough
58+
# to absorb shared-runner noise while still catching real
59+
# regressions. The job doesn't fail; it just comments on the
60+
# offending commit so a human can triage.
61+
alert-threshold: '150%'
62+
comment-on-alert: true
63+
fail-on-alert: false

0 commit comments

Comments
 (0)