-
Notifications
You must be signed in to change notification settings - Fork 4
63 lines (52 loc) · 2.3 KB
/
Copy pathbenchmark.yml
File metadata and controls
63 lines (52 loc) · 2.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
name: Benchmark
on:
pull_request:
branches: [master]
permissions:
contents: read
pull-requests: write
# Cancel a previous in-flight benchmark run when the PR gets a new push.
concurrency:
group: benchmark-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
benchmark:
name: Benchmark Comparison
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout PR
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: stable
# -run='^$' matches no tests, so this runs ONLY benchmarks. Without it,
# `go test -bench` also runs the full unit-test suite (in both checkouts),
# which is what made this job time out at 10m. -benchtime/-count are kept
# modest to keep the PR signal fast; benchstat still flags real regressions.
#
# Results are written to $RUNNER_TEMP, not the workspace: the "Checkout base"
# step below runs actions/checkout again, which cleans the working tree
# (git clean -ffdx) and would otherwise delete pr.bench before benchstat runs.
- name: Run benchmarks on PR
run: go test -bench=. -benchmem -run='^$' -benchtime=100ms -count=6 -timeout=15m ./... | tee "$RUNNER_TEMP/pr.bench"
- name: Checkout base
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
with:
ref: ${{ github.event.pull_request.base.sha }}
- name: Run benchmarks on base
run: go test -bench=. -benchmem -run='^$' -benchtime=100ms -count=6 -timeout=15m ./... | tee "$RUNNER_TEMP/base.bench"
- name: Install benchstat
run: go install golang.org/x/perf/cmd/benchstat@latest
- name: Compare benchmarks
run: |
echo '## Benchmark Comparison' > bench-report.md
echo '' >> bench-report.md
echo '```' >> bench-report.md
benchstat "$RUNNER_TEMP/base.bench" "$RUNNER_TEMP/pr.bench" >> bench-report.md 2>&1 || true
echo '```' >> bench-report.md
- name: Post benchmark results
uses: marocchino/sticky-pull-request-comment@5770ad5eb8f42dd2c4f34da00c94c5381e49af88 # v3.0.5
with:
header: benchmark
path: bench-report.md