Skip to content
Draft
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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
timeout-minutes: 5
steps:
- name: Checkout (previous)
uses: actions/checkout@v3
with:
ref: ${{ github.base_ref }}
path: previous

- name: Checkout (new)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you cloning twice?

You could clone once and switch branches.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It only fetches a single commit by default. If I wanted to clone once and switch, I'd have to fetch all history for all branches and tags. This seems simpler/cleaner.

uses: actions/checkout@v3
with:
path: new

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: '${{ github.workspace }}/new/go.mod'

- name: Install dependencies
run: go install golang.org/x/perf/cmd/benchstat@latest

- name: Run Benchmark (previous)
timeout-minutes: 5
run: |
cd previous
go test -bench=. -benchmem -benchtime=100ms -count=10 ./... > benchmark.txt

- name: Run Benchmark (new)
timeout-minutes: 5
run: |
cd new
go test -bench=. -benchmem -benchtime=100ms -count=10 ./... > benchmark.txt

- name: Run Benchstat
run: benchstat previous/benchmark.txt new/benchmark.txt