Skip to content

ci: add a benchmark workflow #1

ci: add a benchmark workflow

ci: add a benchmark workflow #1

Workflow file for this run

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