-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add benchmark function for getSnippetHash (#758)
* Add benchmark function for getSnippetHash * Add Github Action that posts a comparison * Add value to trigger pipeline * Remove anchors. Not supported * oops, fix benchmark * Implement changes from PR comments
- Loading branch information
1 parent
2626d47
commit 12e8cf0
Showing
2 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
name: benchstat | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
benchstat: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Install Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: '1.19' | ||
|
||
# Generate benchmark report for main branch | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: main | ||
- name: Benchmark | ||
run: go test ./... -count=10 -run="^$" -bench=. -benchmem | tee -a bench.txt | ||
- name: Upload Benchmark | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: bench-current | ||
path: bench.txt | ||
|
||
# Generate benchmark report for the PR | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Benchmark | ||
run: go test ./... -count=10 -run="^$" -bench=. -benchmem | tee -a bench.txt | ||
- name: Upload Benchmark | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: bench-incoming | ||
path: bench.txt | ||
|
||
# Compare the two reports | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Install benchstat | ||
run: go install golang.org/x/perf/cmd/benchstat@latest | ||
- name: Download Incoming | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: bench-incoming | ||
path: bench-incoming | ||
- name: Download Current | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: bench-current | ||
path: bench-current | ||
- name: Benchstat Results | ||
run: benchstat bench-current/bench.txt bench-incoming/bench.txt | tee -a benchstat.txt | ||
- name: Upload benchstat results | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: benchstat | ||
path: benchstat.txt | ||
- name: Read benchstat.txt | ||
id: benchstat_content | ||
uses: juliangruber/read-file-action@v1 | ||
with: | ||
path: ./benchstat.txt | ||
- name: Post PR Comment | ||
uses: thollander/actions-comment-pull-request@v1 | ||
with: | ||
message: | | ||
Benchstat (compared to main): | ||
``` | ||
${{ steps.benchstat_content.outputs.content }} | ||
``` | ||
comment_includes: 'Benchstat (compared to main):' | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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