Skip to content

Commit 66fd58b

Browse files
ci(bench): Add benchmark-action (hairyhenderson#2283)
Signed-off-by: Dave Henderson <[email protected]>
1 parent f4d9693 commit 66fd58b

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

.github/workflows/benchmark.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: go benchmarks
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
8+
jobs:
9+
benchmark:
10+
name: benchmark regression check
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-go@v5
15+
with:
16+
go-version-file: 'go.mod'
17+
- name: Run benchmark
18+
run: make bench.txt
19+
- name: Download previous benchmark data
20+
uses: actions/cache@v4
21+
with:
22+
path: ./cache
23+
key: ${{ runner.os }}-benchmark
24+
- name: Store benchmark result
25+
uses: benchmark-action/github-action-benchmark@v1
26+
with:
27+
tool: 'go'
28+
output-file-path: bench.txt
29+
external-data-json-path: ./cache/benchmark-data.json
30+
fail-on-alert: true
31+
comment-on-alert: true
32+
comment-always: true
33+
github-token: ${{ secrets.GITHUB_TOKEN }}
34+
alert-threshold: "200%"

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ report.xml
88
*.out
99
.netlify
1010
docs/.hugo_build.lock
11+
bench.txt

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ test:
159159
$(GO) test -race -coverprofile=c.out ./...
160160
endif
161161

162+
bench.txt: go.mod go.sum $(GO_FILES)
163+
$(GO) test -benchmem -run=xxx -bench . ./... | tee $@
164+
162165
.SECONDEXPANSION:
163166
testbin/%.test.exe: $$(shell $$(GO) list -f '{{.Dir}}' $$(subst testbin/,,$$(subst .test.exe,,$$@)))
164167
@GOOS=windows GOARCH=amd64 $(GO) test -c -o $@ $<

0 commit comments

Comments
 (0)