Skip to content

Commit

Permalink
Adding GitHub action to compare benchmarks
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pafuent committed Nov 23, 2020
1 parent ad3be08 commit 5b9bbbd
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/echo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,55 @@ jobs:
with:
token:
fail_ci_if_error: false
benchmark:
needs: test
strategy:
matrix:
os: [ubuntu-latest]
go: [1.15]
name: Benchmark comparison ${{ matrix.os }} @ Go ${{ matrix.go }}
runs-on: ${{ matrix.os }}
steps:
- name: Set up Go ${{ matrix.go }}
uses: actions/setup-go@v1
with:
go-version: ${{ matrix.go }}

- name: Set GOPATH and PATH
run: |
echo "GOPATH=$(dirname $GITHUB_WORKSPACE)" >> $GITHUB_ENV
echo "$(dirname $GITHUB_WORKSPACE)/bin" >> $GITHUB_PATH
shell: bash

- name: Set build variables
run: |
echo "GOPROXY=https://proxy.golang.org" >> $GITHUB_ENV
echo "GO111MODULE=on" >> $GITHUB_ENV
- name: Checkout Code (Previous)
uses: actions/checkout@v2
with:
ref: ${{ github.base_ref }}
path: previous

- name: Checkout Code (New)
uses: actions/checkout@v2
with:
path: new

- name: Install Dependencies
run: go get -v golang.org/x/perf/cmd/benchstat

- name: Run Benchmark (Previous)
run: |
cd previous
go test -run="-" -bench=".*" -count=5 ./... > benchmark.txt
- name: Run Benchmark (New)
run: |
cd new
go test -run="-" -bench=".*" -count=5 ./... > benchmark.txt
- name: Run Benchstat
run: |
benchstat previous/benchmark.txt new/benchmark.txt

0 comments on commit 5b9bbbd

Please sign in to comment.