Skip to content

Commit 5b9bbbd

Browse files
committed
Adding GitHub action to compare benchmarks
The GitHub action runs all the benchmarks for the target branch, and the compares those values with the benchmarks results for the PR new code.
1 parent ad3be08 commit 5b9bbbd

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

.github/workflows/echo.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,55 @@ jobs:
6262
with:
6363
token:
6464
fail_ci_if_error: false
65+
benchmark:
66+
needs: test
67+
strategy:
68+
matrix:
69+
os: [ubuntu-latest]
70+
go: [1.15]
71+
name: Benchmark comparison ${{ matrix.os }} @ Go ${{ matrix.go }}
72+
runs-on: ${{ matrix.os }}
73+
steps:
74+
- name: Set up Go ${{ matrix.go }}
75+
uses: actions/setup-go@v1
76+
with:
77+
go-version: ${{ matrix.go }}
78+
79+
- name: Set GOPATH and PATH
80+
run: |
81+
echo "GOPATH=$(dirname $GITHUB_WORKSPACE)" >> $GITHUB_ENV
82+
echo "$(dirname $GITHUB_WORKSPACE)/bin" >> $GITHUB_PATH
83+
shell: bash
84+
85+
- name: Set build variables
86+
run: |
87+
echo "GOPROXY=https://proxy.golang.org" >> $GITHUB_ENV
88+
echo "GO111MODULE=on" >> $GITHUB_ENV
89+
90+
- name: Checkout Code (Previous)
91+
uses: actions/checkout@v2
92+
with:
93+
ref: ${{ github.base_ref }}
94+
path: previous
95+
96+
- name: Checkout Code (New)
97+
uses: actions/checkout@v2
98+
with:
99+
path: new
100+
101+
- name: Install Dependencies
102+
run: go get -v golang.org/x/perf/cmd/benchstat
103+
104+
- name: Run Benchmark (Previous)
105+
run: |
106+
cd previous
107+
go test -run="-" -bench=".*" -count=5 ./... > benchmark.txt
108+
109+
- name: Run Benchmark (New)
110+
run: |
111+
cd new
112+
go test -run="-" -bench=".*" -count=5 ./... > benchmark.txt
113+
114+
- name: Run Benchstat
115+
run: |
116+
benchstat previous/benchmark.txt new/benchmark.txt

0 commit comments

Comments
 (0)