Skip to content

Commit

Permalink
ci: Add a new benchmark recording workflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaqx0r committed May 4, 2024
1 parent d6fd429 commit 3d6a6f2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
35 changes: 35 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: benchmark
on:
pull_request: # for testing
push:
branches:
- main

jobs:
benchmark:
runs-on: ubuntu-latest
permissions:
# For benchmark-action summary-always
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
cache: true
- run: make bench
env:
HEAD_REF: ${{ env.GITHUB_REF_NAME }}
BENCH_COUNT: 1
- uses: actions/cache@v4
with:
path: ./cache
key: ${{ runner.os }}-benchmark
- uses: benchmark-action/[email protected]
with:
tool: 'go'
output-file-path: test-results/benchmark-results-${{ env.GITHUB_REF_NAME }}.txt
external-data-json-path: ./cache/benchmark-data.json
github-token: ${{ secrets.GITHUB_TOKEN }}
comment-always: true
summary-always: true
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ $(TESTRESULTS)/test-output.xml $(TESTCOVERPROFILE): $(GOFILES) $(GOGENFILES) $(G
bench: $(TESTRESULTS)/benchmark-results-$(HEAD_REF).txt
$(TESTRESULTS)/benchmark-results-$(HEAD_REF).txt: $(GOFILES) $(GOGENFILES) $(GOTESTFILES) | print-version .dep-stamp
mkdir -p $(TESTRESULTS)
go test -cpu 1,2,4 -bench=. -count=$(BENCH_COUNT) -timeout=${benchtimeout} -run=^a ./... | tee $@
go test -cpu 1 -bench=BenchmarkMetric -count=$(BENCH_COUNT) -timeout=${benchtimeout} -run=^a ./... | tee $@

.PHONY: benchstat
benchstat: $(TESTRESULTS)/benchstat.txt
Expand Down

0 comments on commit 3d6a6f2

Please sign in to comment.