Skip to content

Commit 6d7d7d6

Browse files
committed
Run diff / bench in parallel
1 parent ebf0d8b commit 6d7d7d6

File tree

1 file changed

+43
-10
lines changed

1 file changed

+43
-10
lines changed

.github/workflows/diff.yml

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,61 @@ on:
55
branches: [ master ]
66

77
jobs:
8-
bench:
8+
benchmark:
99
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
ref: [master, ${{ github.sha }}]
13+
include:
14+
- ref: master
15+
name: old
16+
- ref: ${{ github.sha }}
17+
name: new
1018
steps:
1119
- name: Setup Go 1.18
1220
uses: actions/setup-go@v4
1321
with:
1422
go-version: 1.18
23+
24+
- name: Checkout code
25+
uses: actions/checkout@v3
26+
with:
27+
ref: ${{ matrix.ref }}
28+
29+
- name: Run benchmark
30+
run: go test -bench=. -benchmem -run=^$ -count=10 -timeout=30m | tee /tmp/${{ matrix.name }}.txt
31+
32+
- name: Upload benchmark results
33+
uses: actions/upload-artifact@v3
34+
with:
35+
name: benchmark-${{ matrix.name }}
36+
path: /tmp/${{ matrix.name }}.txt
37+
38+
compare:
39+
needs: benchmark
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Setup Go 1.18
43+
uses: actions/setup-go@v4
44+
with:
45+
go-version: 1.18
46+
1547
- name: Install benchstat
1648
# NOTE: benchstat@latest requires go 1.23 since 2025-02-14 - this is the last go 1.18 ref
1749
# https://cs.opensource.google/go/x/perf/+/c95ad7d5b636f67d322a7e4832e83103d0fdd292
1850
run: go install golang.org/x/perf/cmd/benchstat@884df5810d2850d775c2cb4885a7ea339128a17d
1951

20-
- uses: actions/checkout@v3
21-
- name: Benchmark new code
22-
run: go test -bench=. -benchmem -run=^$ -count=10 -timeout=30m | tee /tmp/new.txt
52+
- name: Download old benchmark results
53+
uses: actions/download-artifact@v3
54+
with:
55+
name: benchmark-old
56+
path: /tmp/
2357

24-
- name: Checkout master
25-
uses: actions/checkout@v3
58+
- name: Download new benchmark results
59+
uses: actions/download-artifact@v3
2660
with:
27-
ref: master
28-
- name: Benchmark master
29-
run: go test -bench=. -benchmem -run=^$ -count=10 -timeout=30m | tee /tmp/old.txt
61+
name: benchmark-new
62+
path: /tmp/
3063

31-
- name: Diff
64+
- name: Compare benchmarks
3265
run: benchstat /tmp/old.txt /tmp/new.txt

0 commit comments

Comments
 (0)