Skip to content

Commit

Permalink
add benchmark action that leaves comment on PR (#588)
Browse files Browse the repository at this point in the history
* better benchmarks

benchmark each detector with negative and positive inputs

* add benchmark action that leaves comment on PR
  • Loading branch information
gabriel-vasile authored Oct 11, 2024
1 parent c6c5e4f commit 7798415
Show file tree
Hide file tree
Showing 2 changed files with 283 additions and 285 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/benchmark.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Run benchmarks
on:
pull_request:
branches: [master]

permissions:
contents: read

jobs:
benchmark:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v5.0.2
with:
go-version-file: 'go.mod'
- run: go install golang.org/x/perf/cmd/benchstat@latest
// Base for comparison is master branch.
- name: Checkout code
uses: actions/checkout@v4.1.7
with:
ref: master
- run: go test -run=none -bench=. --count=7 > /tmp/prev &

- name: Checkout code
uses: actions/checkout@v4.1.7
- run: go test -run=none -bench=. --count=7 > /tmp/curr &

// Wait for both benchmarks to complete before comparing.
- run: wait
- run: RESULT="$(benchstat /tmp/prev /tmp/curr)"
- uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: $RESULT
})
Loading

0 comments on commit 7798415

Please sign in to comment.