Go 项目的持续性基准
cob compares benchmarks between the latest commit (HEAD) and the previous commit (HEAD{@1}). The program will fail if the change in score is worse than the threshold. This tools is suitable for CI/CD to detect a regression of a performance automatically.
cob runs go test -bench before and after commit internally, so it depends on go command.
CAUTION: Note that git reset is executed when you run cob. You should commit all changes before running cob.
See cob-example for details.
name: Bench
on: [push, pull_request]
jobs:
test:
name: Bench
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.13
uses: actions/setup-go@v1
with:
go-version: 1.13
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Install cob
run: curl -sfL https://raw.githubusercontent.com/knqyf263/cob/master/install.sh | sudo sh -s -- -b /usr/local/bin
- name: Run Benchmark
run: cobdist: bionic
language: go
go:
- 1.13.x
before_script:
- curl -sfL https://raw.githubusercontent.com/knqyf263/cob/master/install.sh | sudo sh -s -- -b /usr/local/bin
script:
- cobversion: 2
jobs:
bench:
docker:
- image: circleci/golang:1.13
steps:
- checkout
- run:
name: Install cob
command: curl -sfL https://raw.githubusercontent.com/knqyf263/cob/master/install.sh | sudo sh -s -- -b /usr/local/bin
- run:
name: Run cob
command: cob
workflows:
version: 2
build-workflow:
jobs:
- benchTo measure benchmarks by make bench, you can use -bench-cmd and -bench-args options.
$ cob -bench-cmd make -bench-args bench$ cob -bench-args "test -bench Append -benchmem ./..."Result
…$ cob -only-degressionResult
2020/01/12 17:48:35 Run Benchmark: 4363944cbed3da7a8245cbcdc8d8240b8976eb24 HEAD{@1}
2020/01/12 17:48:38 Run Benchmark: 599a5523729d4d99a331b9d3f71dde9e1e6daef0 HEAD
Comparison
==========
+-----------------------------+---------+-------------------+
| Name | NsPerOp | AllocedBytesPerOp |
+-----------------------------+---------+-------------------+
| BenchmarkAppend_Allocate-16 | 52.34% | 347.83% |
+-----------------------------+---------+-------------------+
2020/01/12 17:48:39 This commit makes benchmarks worseThe following option means the program fails if a benchmark score gets worse than 50%.
$ cob -threshold 0.5 ./...By default, cob uses HEAD~1. If you compare benchmarks with different commit, you can use --base option.
$ cob --base origin/master ./...You can use -compare option.
$ cob -compare B/opResult
…If your commit message contains [skip cob], cob is skipped.
$ git add README.md
$ git commit -m "[skip cob] update README.md"
$ cob
2020/04/19 12:46:57 [skip cob] is detected, so the benchmark is skipped…Specify a package name.
$ cob -bench-args "test -bench . -benchmem ./foo"
$ cob -bench-args "test -bench . -benchmem ./bar" You can specify -benchtime.
$ cob -bench-args "test -bench . -benchmem -benchtime 10s ./..." This repository is available under the MIT
Teppei Fukuda (knqyf263)
暂无开放 Issues,或尚未同步最近议题。