Skip to content

Commit 68138bf

Browse files
committed
ci: add a benchmark workflow
1 parent 36bf99d commit 68138bf

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

.github/workflows/bench.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Benchstat
2+
3+
on:
4+
pull_request:
5+
branches: [ master ]
6+
7+
permissions: # added using https://github.com/step-security/secure-workflows
8+
contents: read
9+
10+
jobs:
11+
12+
bench:
13+
name: Performance regression check
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout (previous)
17+
uses: actions/checkout@v3
18+
with:
19+
ref: ${{ github.base_ref }}
20+
path: previous
21+
22+
- name: Checkout (new)
23+
uses: actions/checkout@v3
24+
with:
25+
path: new
26+
27+
- name: Set up Go
28+
uses: actions/setup-go@v4
29+
with:
30+
go-version-file: '${{ github.workspace }}/go.mod'
31+
32+
- name: Install dependencies
33+
run: go install golang.org/x/perf/cmd/benchstat@latest
34+
35+
- name: Run Benchmark (previous)
36+
run: |
37+
cd previous
38+
go test -bench=. -benchmem -benchtime=100ms -count=8 > benchmark.txt
39+
40+
- name: Run Benchmark (new)
41+
run: |
42+
cd new
43+
go test -bench=. -benchmem -benchtime=100ms -count=8 > benchmark.txt
44+
45+
- name: Run Benchstat
46+
run: benchstat previous/benchmark.txt new/benchmark.txt

0 commit comments

Comments
 (0)