Skip to content

Commit

Permalink
chore(bench): display bench stats as comment in PR
Browse files Browse the repository at this point in the history
Fixes #992

Signed-off-by: Xavier Coulon <[email protected]>
  • Loading branch information
xcoulon committed Apr 18, 2022
1 parent af34ca7 commit e4fee51
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
29 changes: 19 additions & 10 deletions .github/workflows/ci-bench.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
name: ci-build
name: ci-bench
on:
push:
branches:
- master
tags-ignore:
- '*.*'
pull_request:
pull_request_target:
branches:
- master

jobs:
test:
bench:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [1.16.x,1.17.x]
go-version: [1.17.x]
os: [ubuntu-latest]
name: Benchstat with Go ${{ matrix.go-version }}

Expand All @@ -38,11 +33,25 @@ jobs:
${{ runner.os }}-go-
- name: Verify parser
if: runner.os == 'Linux'
run: |
make verify-parser
- name: Bench and Diff
id: bench-diff
run: |
go install golang.org/x/perf/cmd/benchstat@latest
make bench-diff
echo "::set-output name=summary::$(make print-bench-diff)"
- name: Comment Benchmark Diffs
uses: marocchino/sticky-pull-request-comment@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
header: bench
message: |
### Benchmark Diffs
<details><summary>Benchmark diffs</summary>
```
${{ steps.bench-diff.outputs.summary }}
```
</details>
2 changes: 1 addition & 1 deletion .github/workflows/ci-release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: goreleaser
name: ci-release

on:
push:
Expand Down
6 changes: 4 additions & 2 deletions make/bench.mk
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ bench-diff: clean generate-optimized check-git-status
| tee $(REPORTS_DIR)/v0.7.0.bench
@echo "generated $(REPORTS_DIR)/v0.7.0.bench"
@git checkout $(GIT_BRANCH_NAME)
@echo ""
@echo "Comparing with 'master' branch"
@$(GOPATH)/bin/benchstat $(REPORTS_DIR)/$(GIT_BRANCH_NAME)-$(GIT_COMMIT_ID_SHORT).bench $(REPORTS_DIR)/master.bench
@echo ""
@echo "Comparing with 'v0.7.0' tag"
@$(GOPATH)/bin/benchstat $(REPORTS_DIR)/$(GIT_BRANCH_NAME)-$(GIT_COMMIT_ID_SHORT).bench $(REPORTS_DIR)/v0.7.0.bench
@$(GOPATH)/bin/benchstat $(REPORTS_DIR)/$(GIT_BRANCH_NAME)-$(GIT_COMMIT_ID_SHORT).bench $(REPORTS_DIR)/v0.7.0.bench | tee $(REPORTS_DIR)/diffs.txt

print-bench-diff:
@cat $(REPORTS_DIR)/diffs.txt

check-git-status:
ifneq ("$(shell git status --porcelain)","")
@echo "Repository contains uncommitted changes:"
Expand Down

0 comments on commit e4fee51

Please sign in to comment.