Skip to content

Commit

Permalink
ci: add a benchmark workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
sbruens committed Mar 27, 2024
1 parent 36bf99d commit 68138bf
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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

0 comments on commit 68138bf

Please sign in to comment.