-
Notifications
You must be signed in to change notification settings - Fork 53
82 lines (66 loc) · 2.12 KB
/
benchmark.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: performance
on:
pull_request:
types: [opened, reopened]
jobs:
benchmark:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Install dependencies
run: go get .
- name: Set Golang binaries path
run: echo "`go env GOPATH`/bin" >> $GITHUB_PATH
- name: Install benchstat
run: go install golang.org/x/perf/cmd/benchstat@latest
- name: Run golang benchmarks
run: go test -run="^$" -bench=. -count=10 ./internal/... > benchmark.txt
- name: Download baseline benchmark
id: download
uses: actions/download-artifact@v4
with:
name: baseline-benchmark
path: stats/benchmark.txt
continue-on-error: true
- name: Use current benchmark as reference
if: steps.download.outcome != 'success'
run: |
mkdir stats
cp benchmark.txt stats/benchmark.txt
- name: Compare benchmark results
run: |
benchstat -table col -row .name -format=csv stats/benchmark.txt benchmark.txt | grep '^[A-Z]' > stats.csv
- name: Upload benchstat results
uses: actions/upload-artifact@v4
with:
name: benchstat-results
path: stats.csv
overwrite: true
parse-results:
runs-on: ubuntu-latest
needs: [benchmark]
steps:
- uses: actions/setup-python@v5
with:
python-version: '3:12'
- name: Download benchstats result
uses: actions/download-artifact@v4
with:
name: benchstat-results
path: stats.csv
- name: Install dependencies
run: |
pip install --upgrade pip
pip install pandas
- name: Evaluate the results
uses: jannekem/run-python-script-action@v1
with:
script: |
import pandas as pd
df = pd.read_csv('stats.csv', names=['name','reference','secs/op','benchmark','_secs/op','change','P'])
df.change = df.change.replace("~", "0")
df.change = df.change.str.rstrip("%")
print(df.loc[df.change > 20, ['name','change','P']])