diff --git a/.travis.yml b/.travis.yml index cfb8383..e660740 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,3 +7,5 @@ env: go: [1.12.x, 1.13.x] services: - redis-server +after_success: + - bash ./.travis/benchcmp.sh diff --git a/.travis/benchcmp.sh b/.travis/benchcmp.sh new file mode 100755 index 0000000..b66801c --- /dev/null +++ b/.travis/benchcmp.sh @@ -0,0 +1,15 @@ +if [ "${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}" != "master" ]; then + REMOTE_URL="$(git config --get remote.origin.url)"; + cd ${TRAVIS_BUILD_DIR}/.. && \ + git clone ${REMOTE_URL} "${TRAVIS_REPO_SLUG}-bench" && \ + cd "${TRAVIS_REPO_SLUG}-bench" && \ + # Benchmark master + git checkout master && \ + go test -run=XXX -bench=. ./... > master.txt && \ + # Benchmark feature branch + git checkout ${TRAVIS_COMMIT} && \ + go test -run=XXX -bench=. ./... > feature.txt && \ + go get -u golang.org/x/tools/cmd/benchcmp && \ + # compare two benchmarks + benchcmp master.txt feature.txt; +fi \ No newline at end of file