Skip to content

Commit 6408c34

Browse files
ci(bench): Add benchmark-action (#900)
Signed-off-by: Dave Henderson <[email protected]>
1 parent 05ed51d commit 6408c34

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-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@v4
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%"

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ endif
3333
test:
3434
go test $(TEST_ARGS) -coverprofile=c.out ./...
3535

36+
bench.txt:
37+
go test -benchmem -run=xxx -bench . ./... | tee $@
38+
3639
bin/fscli_%v7$(call extension,$(GOOS)): $(shell find . -type f -name "*.go")
3740
GOOS=$(shell echo $* | cut -f1 -d-) \
3841
GOARCH=$(shell echo $* | cut -f2 -d- ) \

0 commit comments

Comments
 (0)