From 6f82a443376bb364e5715544fc1043ab2df7e870 Mon Sep 17 00:00:00 2001 From: Ken Hibino Date: Fri, 29 Jan 2021 15:49:49 -0800 Subject: [PATCH] Add github workflow to benchmark incoming change against master --- .github/workflows/benchstat.yml | 86 +++++++++++++++++++++++++++++++++ .github/workflows/go.yml | 3 ++ 2 files changed, 89 insertions(+) create mode 100644 .github/workflows/benchstat.yml diff --git a/.github/workflows/benchstat.yml b/.github/workflows/benchstat.yml new file mode 100644 index 0000000..eb89df2 --- /dev/null +++ b/.github/workflows/benchstat.yml @@ -0,0 +1,86 @@ +# This workflow runs benchmarks against the current branch, compares them to benchmarks against +# master, and uploads the results as an artifact. + +# TODO: This workflow could be improved by only running on pull requests and then posting the results back +# as a comment in the pull request. + +name: Benchstat + +on: [push, pull_request] + +jobs: + incoming: + runs-on: ubuntu-latest + services: + redis: + image: redis + ports: + - 6379:637 + steps: + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: 1.15.x + - name: Checkout + uses: actions/checkout@v2 + - name: Benchmark + run: | + for i in {1..5}; do + go test -run=^$ -bench=. ./... | tee -a bench.txt + done + - name: Upload Benchmark + uses: actions/upload-artifact@v2 + with: + name: bench-incoming + path: bench.txt + current: + runs-on: ubuntu-latest + services: + redis: + image: redis + ports: + - 6379:637 + steps: + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: 1.15.x + - name: Checkout + uses: actions/checkout@v2 + with: + ref: master + - name: Benchmark + run: | + for i in {1..5}; do + go test -run=^$ -bench=. ./... | tee -a bench.txt + done + - name: Upload Benchmark + uses: actions/upload-artifact@v2 + with: + name: bench-current + path: bench.txt + benchstat: + needs: [incoming, current] + runs-on: ubuntu-latest + steps: + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: 1.15.x + - name: Install benchstat + run: go get -u golang.org/x/perf/cmd/benchstat + - name: Download Incoming + uses: actions/download-artifact@v2 + with: + name: bench-incoming + - name: Download Current + uses: actions/download-artifact@v2 + with: + name: 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@v2 + with: + name: benchstat + path: benchstat.txt diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index d881004..e52964a 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -28,3 +28,6 @@ jobs: - name: Test run: go test -race -v ./... + + - name: Bench Test + run: go test -run=^$ -bench=. -loglevel=debug ./...