|
5 | 5 | branches: [ master ] |
6 | 6 |
|
7 | 7 | jobs: |
8 | | - benchmark: |
| 8 | + bench: |
9 | 9 | 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 |
18 | 10 | steps: |
19 | 11 | - name: Setup Go 1.18 |
20 | 12 | uses: actions/setup-go@v4 |
21 | 13 | with: |
22 | 14 | 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 | | - |
47 | 15 | - name: Install benchstat |
48 | 16 | # NOTE: benchstat@latest requires go 1.23 since 2025-02-14 - this is the last go 1.18 ref |
49 | 17 | # https://cs.opensource.google/go/x/perf/+/c95ad7d5b636f67d322a7e4832e83103d0fdd292 |
50 | 18 | run: go install golang.org/x/perf/cmd/benchstat@884df5810d2850d775c2cb4885a7ea339128a17d |
51 | 19 |
|
52 | | - - name: Download old benchmark results |
53 | | - uses: actions/download-artifact@v3 |
54 | | - with: |
55 | | - name: benchmark-old |
56 | | - path: /tmp/ |
| 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 |
57 | 23 |
|
58 | | - - name: Download new benchmark results |
59 | | - uses: actions/download-artifact@v3 |
| 24 | + - name: Checkout master |
| 25 | + uses: actions/checkout@v3 |
60 | 26 | with: |
61 | | - name: benchmark-new |
62 | | - path: /tmp/ |
| 27 | + ref: master |
| 28 | + - name: Benchmark master |
| 29 | + run: go test -bench=. -benchmem -run=^$ -count=10 -timeout=30m | tee /tmp/old.txt |
63 | 30 |
|
64 | | - - name: Compare benchmarks |
| 31 | + - name: Diff |
65 | 32 | run: benchstat /tmp/old.txt /tmp/new.txt |
0 commit comments