ci: add a benchmark workflow #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Benchstat | |
on: | |
pull_request: | |
branches: [ master ] | |
permissions: # added using https://github.com/step-security/secure-workflows | |
contents: read | |
jobs: | |
bench: | |
name: Performance regression check | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout (previous) | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.base_ref }} | |
path: previous | |
- name: Checkout (new) | |
uses: actions/checkout@v3 | |
with: | |
path: new | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: '${{ github.workspace }}/go.mod' | |
- name: Install dependencies | |
run: go install golang.org/x/perf/cmd/benchstat@latest | |
- name: Run Benchmark (previous) | |
run: | | |
cd previous | |
go test -bench=. -benchmem -benchtime=100ms -count=8 > benchmark.txt | |
- name: Run Benchmark (new) | |
run: | | |
cd new | |
go test -bench=. -benchmem -benchtime=100ms -count=8 > benchmark.txt | |
- name: Run Benchstat | |
run: benchstat previous/benchmark.txt new/benchmark.txt |