2020-01-31 12:37:28 +08:00
|
|
|
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" && \
|
2020-09-13 21:03:11 +08:00
|
|
|
# turn the detached message off
|
|
|
|
git config --global advice.detachedHead false && \
|
2020-01-31 12:37:28 +08:00
|
|
|
cd "${TRAVIS_REPO_SLUG}-bench" && \
|
2020-06-08 04:04:27 +08:00
|
|
|
|
2020-01-31 12:37:28 +08:00
|
|
|
# Benchmark master
|
|
|
|
git checkout master && \
|
2020-09-13 21:03:11 +08:00
|
|
|
go test -run=^$ -bench=. -count=5 -timeout=60m -benchmem ./... > master.txt && \
|
2020-06-08 04:04:27 +08:00
|
|
|
|
2020-01-31 12:37:28 +08:00
|
|
|
# Benchmark feature branch
|
|
|
|
git checkout ${TRAVIS_COMMIT} && \
|
2020-09-13 21:03:11 +08:00
|
|
|
go test -run=^$ -bench=. -count=5 -timeout=60m -benchmem ./... > feature.txt && \
|
2020-06-08 04:04:27 +08:00
|
|
|
|
2020-01-31 12:37:28 +08:00
|
|
|
# compare two benchmarks
|
2020-09-13 21:03:11 +08:00
|
|
|
go get -u golang.org/x/perf/cmd/benchstat && \
|
|
|
|
benchstat master.txt feature.txt;
|
2020-06-08 04:04:27 +08:00
|
|
|
fi
|