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