Debian Codegraph @

.github/workflows/benchmark.yml

raw
1 ---
2 name: Benchmark
3
4 "on":
5 - pull_request
6
7 jobs:
8 benchmark:
9 strategy:
10 matrix:
11 ref:
12 - master
13 - ${{ github.sha }}
14
15 runs-on: ubuntu-latest
16
17 steps:
18 - name: Setup Go
19 uses: actions/setup-go@v2
20 with:
21 go-version: "1.24"
22
23 - name: Checkout
24 uses: actions/checkout@v2
25 with:
26 ref: ${{ matrix.ref }}
27
28 - name: Run Benchmarks
29 # Without 6 iterations, benchstat will claim statistical insignificance.
30 run: go test -v -run '^$' -bench '(Marshal|Unmarshal)$/codeResponse' -benchmem -benchtime 3s -cpu 1 -count 6 ./json | tee bench.txt
31
32 - name: Upload Benchmarks
33 uses: actions/upload-artifact@v4
34 with:
35 name: ${{ matrix.ref }}
36 path: bench.txt
37
38 benchstat:
39 needs: [benchmark]
40 runs-on: ubuntu-latest
41
42 steps:
43 - name: Setup Go
44 uses: actions/setup-go@v2
45 with:
46 go-version: "1.24"
47
48 - name: Setup Benchstat
49 run: go install golang.org/x/perf/cmd/benchstat@latest
50
51 - name: Download Benchmark Results
52 uses: actions/download-artifact@v4
53 with:
54 path: .
55
56 - name: Run Benchstat
57 run: benchstat ./master/bench.txt ./${{ github.sha }}/bench.txt | tee benchstat.txt
58
59 - name: Upload Benchstat Results
60 uses: actions/upload-artifact@v4
61 with:
62 name: benchstat
63 path: benchstat.txt