2021-01-30 14:59:28 +08:00
|
|
|
# This workflow runs benchmarks against the current branch,
|
|
|
|
# compares them to benchmarks against master,
|
|
|
|
# and uploads the results as an artifact.
|
|
|
|
|
|
|
|
name: benchstat
|
|
|
|
|
|
|
|
on: [pull_request]
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
incoming:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
services:
|
|
|
|
redis:
|
2023-12-07 16:49:23 +08:00
|
|
|
image: redis:7
|
2021-01-30 14:59:28 +08:00
|
|
|
ports:
|
|
|
|
- 6379:6379
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2023-12-07 16:49:23 +08:00
|
|
|
uses: actions/checkout@v4
|
2021-01-30 14:59:28 +08:00
|
|
|
- name: Set up Go
|
2023-12-07 16:49:23 +08:00
|
|
|
uses: actions/setup-go@v4
|
2021-01-30 14:59:28 +08:00
|
|
|
with:
|
2023-12-07 16:49:23 +08:00
|
|
|
go-version: 1.21.x
|
2021-01-30 14:59:28 +08:00
|
|
|
- name: Benchmark
|
|
|
|
run: go test -run=^$ -bench=. -count=5 -timeout=60m ./... | tee -a new.txt
|
|
|
|
- name: Upload Benchmark
|
2023-12-07 16:49:23 +08:00
|
|
|
uses: actions/upload-artifact@v3
|
2021-01-30 14:59:28 +08:00
|
|
|
with:
|
|
|
|
name: bench-incoming
|
|
|
|
path: new.txt
|
|
|
|
|
|
|
|
current:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
services:
|
|
|
|
redis:
|
2023-12-07 16:49:23 +08:00
|
|
|
image: redis:7
|
2021-01-30 14:59:28 +08:00
|
|
|
ports:
|
|
|
|
- 6379:6379
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2023-12-07 16:49:23 +08:00
|
|
|
uses: actions/checkout@v4
|
2021-01-30 14:59:28 +08:00
|
|
|
with:
|
|
|
|
ref: master
|
|
|
|
- name: Set up Go
|
2023-12-07 16:49:23 +08:00
|
|
|
uses: actions/setup-go@v4
|
2021-01-30 14:59:28 +08:00
|
|
|
with:
|
2023-12-07 16:49:23 +08:00
|
|
|
go-version: 1.21.x
|
2021-01-30 14:59:28 +08:00
|
|
|
- name: Benchmark
|
|
|
|
run: go test -run=^$ -bench=. -count=5 -timeout=60m ./... | tee -a old.txt
|
|
|
|
- name: Upload Benchmark
|
2023-12-07 16:49:23 +08:00
|
|
|
uses: actions/upload-artifact@v3
|
2021-01-30 14:59:28 +08:00
|
|
|
with:
|
|
|
|
name: bench-current
|
|
|
|
path: old.txt
|
|
|
|
|
|
|
|
benchstat:
|
|
|
|
needs: [incoming, current]
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2023-12-07 16:49:23 +08:00
|
|
|
uses: actions/checkout@v4
|
2021-01-30 14:59:28 +08:00
|
|
|
- name: Set up Go
|
2023-12-07 16:49:23 +08:00
|
|
|
uses: actions/setup-go@v4
|
2021-01-30 14:59:28 +08:00
|
|
|
with:
|
2023-12-07 16:49:23 +08:00
|
|
|
go-version: 1.21.x
|
2021-01-30 14:59:28 +08:00
|
|
|
- name: Install benchstat
|
|
|
|
run: go get -u golang.org/x/perf/cmd/benchstat
|
|
|
|
- name: Download Incoming
|
2023-12-07 16:49:23 +08:00
|
|
|
uses: actions/download-artifact@v3
|
2021-01-30 14:59:28 +08:00
|
|
|
with:
|
|
|
|
name: bench-incoming
|
|
|
|
- name: Download Current
|
2023-12-07 16:49:23 +08:00
|
|
|
uses: actions/download-artifact@v3
|
2021-01-30 14:59:28 +08:00
|
|
|
with:
|
|
|
|
name: bench-current
|
|
|
|
- name: Benchstat Results
|
|
|
|
run: benchstat old.txt new.txt | tee -a benchstat.txt
|
|
|
|
- name: Upload benchstat results
|
2023-12-07 16:49:23 +08:00
|
|
|
uses: actions/upload-artifact@v3
|
2021-01-30 14:59:28 +08:00
|
|
|
with:
|
|
|
|
name: benchstat
|
|
|
|
path: benchstat.txt
|