Skip to content

Commit dea1303

Browse files
committed
ci: parse the results of benchstats
Parse the results of the GH actions and return output that has 20% decrease in performance. Signed-off-by: Edmund Ochieng <[email protected]>
1 parent 1434a08 commit dea1303

File tree

1 file changed

+48
-12
lines changed

1 file changed

+48
-12
lines changed

Diff for: .github/workflows/benchmark.yaml

+48-12
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,66 @@ jobs:
1717
- name: Install dependencies
1818
run: go get .
1919

20-
- name: Run golang benchmarks
21-
run: go test -run="^$" -bench=. ./internal/...
20+
- name: Set Golang binaries path
21+
run: echo "`go env GOPATH`/bin" >> $GITHUB_PATH
2222

2323
- name: Install benchstat
2424
run: go install golang.org/x/perf/cmd/benchstat@latest
2525

26-
- name: Set Golang binaries path
27-
run: echo "`go env GOPATH`/bin" >> $GITHUB_PATH
26+
- name: Run golang benchmarks
27+
run: go test -run="^$" -bench=. -count=10 ./internal/... > benchmark.txt
2828

29-
- name: Download previous benchmarks
29+
- name: Download baseline benchmark
3030
id: download
3131
uses: actions/download-artifact@v4
3232
with:
33-
name: benchmark-results
33+
name: baseline-benchmark
3434
path: stats/benchmark.txt
3535
continue-on-error: true
3636

37+
- name: Use current benchmark as reference
38+
if: steps.download.outcome != 'success'
39+
run: |
40+
mkdir stats
41+
cp benchmark.txt stats/benchmark.txt
42+
3743
- name: Compare benchmark results
38-
if: steps.download.outcome == 'success'
39-
run: benchstat benchmark.txt stats/benchmark.txt
44+
run: |
45+
benchstat -table col -row .name -format=csv stats/benchmark.txt benchmark.txt | grep '^[A-Z]' > stats.csv
4046
41-
- name: Upload artifacts
47+
- name: Upload benchstat results
4248
uses: actions/upload-artifact@v4
4349
with:
44-
name: benchmark-results
45-
path: benchmark.txt
46-
overwrite: true
50+
name: benchstat-results
51+
path: stats.csv
52+
overwrite: true
53+
54+
parse-results:
55+
runs-on: ubuntu-latest
56+
needs: [benchmark]
57+
steps:
58+
- uses: actions/setup-python@v5
59+
with:
60+
python-version: '3:12'
61+
62+
- name: Download benchstats result
63+
uses: actions/download-artifact@v4
64+
with:
65+
name: benchstat-results
66+
path: stats.csv
67+
68+
- name: Install dependencies
69+
run: |
70+
pip install --upgrade pip
71+
pip install pandas
72+
73+
- name: Evaluate the results
74+
uses: jannekem/run-python-script-action@v1
75+
with:
76+
script: |
77+
import pandas as pd
78+
79+
df = pd.read_csv('stats.csv', names=['name','reference','secs/op','benchmark','_secs/op','change','P'])
80+
df.change = df.change.replace("~", "0")
81+
df.change = df.change.str.rstrip("%")
82+
print(df.loc[df.change > 20, ['name','change','P']])

0 commit comments

Comments
 (0)