Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

Commit

Permalink
ci(travis): redo benchmarks with travis
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahhoward committed Jun 30, 2019
1 parent a33adb2 commit 2a6239e
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 128 deletions.
119 changes: 0 additions & 119 deletions .circleci/config.yml

This file was deleted.

8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ go:
env:
global:
- GOTFLAGS="-race"
matrix:
- BUILD_DEPTYPE=gomod

matrix:
- TEST_PHASE=test
- TEST_PHASE=benchmark

# disable travis install
install:
- true

script:
- bash <(curl -s https://raw.githubusercontent.com/ipfs/ci-helpers/master/travis-ci/run-standard-tests.sh)

- ./bin/test-exec.sh

cache:
directories:
Expand Down
7 changes: 7 additions & 0 deletions bin/benchmark-to-file.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
output="$1"
branch="$2"

git checkout "$2"

IPFS_LOGGING=critical go test -run=NONE -bench=. ./... | tee "$1"
8 changes: 4 additions & 4 deletions bin/diff-benchmarks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ parse() {
sed -n \
-e 's/ *\t */\t/g' \
-e '/^Benchmark/p' |
column -s' ' --json \
--table-columns name,count,time,rate \
--table-name "results" |
jq '.results[] | {name: .name, time: (.time | rtrimstr(" ns/op") | tonumber)}'
awk 'BEGIN{print "{\"results\": ["} {print " {\"name\": \"",$1,"\", \"time\": ",$3," },"} END{print "]}"}' OFS="" ORS=" "|
sed -e 's/, ]/ ]/g' |
jq '.results[] | {name: .name, time: .time }'

}

benchcmp "$1" "$2"
Expand Down
61 changes: 61 additions & 0 deletions bin/run-benchmarks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash
set -eo pipefail

display_and_run() {
echo "***" "$@"
eval $(printf '%q ' "$@")
}

# reset workdir to state from git (to remove possible rewritten dependencies)
display_and_run git reset --hard

# Environment
echo "*** Setting up test environment"
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
if [[ "$TRAVIS_SUDO" == true ]]; then
# Ensure that IPv6 is enabled.
# While this is unsupported by TravisCI, it still works for localhost.
sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=0
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=0
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0
fi
else
# OSX has a default file limit of 256, for some tests we need a
# maximum of 8192.
ulimit -Sn 8192
fi

list_buildable() {
go list -f '{{if (len .GoFiles)}}{{.ImportPath}} {{if .Module}}{{.Module.Dir}}{{else}}{{.Dir}}{{end}}{{end}}' ./... | grep -v /vendor/
}

build_all() {
# Make sure everything can compile since some package may not have tests
# Note: that "go build ./..." will fail if some packages have only
# tests (will get "no buildable Go source files" error) so we
# have to do this the hard way.
list_buildable | while read -r pkg dir; do
echo '*** go build' "$pkg"
buildmode=archive
if [[ "$(go list -f '{{.Name}}')" == "main" ]]; then
# plugin works even when a "main" function is missing.
buildmode=plugin
fi
( cd "$dir"; go build -buildmode=$buildmode -o /dev/null "$pkg")
done
}

export GO111MODULE=on
display_and_run go get golang.org/x/tools/cmd/benchcmp
build_all
git checkout -b after
git fetch origin master:refs/remotes/origin/before
git checkout remotes/origin/before
git checkout -b before
git checkout after
display_and_run ./bin/benchmark-to-file.sh benchmark-before.txt before
git checkout after
display_and_run ./bin/benchmark-to-file.sh benchmark-after.txt after
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
display_and_run ./bin/diff-benchmarks.sh benchmark-before.txt benchmark-after.txt
fi
6 changes: 6 additions & 0 deletions bin/test-exec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
if [[ "$TEST_PHASE" == "test" ]]; then
bash <(curl -s https://raw.githubusercontent.com/ipfs/ci-helpers/master/travis-ci/run-standard-tests.sh)
else
./bin/run-benchmarks.sh
fi
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ require (
golang.org/x/net v0.0.0-20190611141213-3f473d35a33a // indirect
golang.org/x/sys v0.0.0-20190610200419-93c9922d18ae // indirect
golang.org/x/text v0.3.2 // indirect
golang.org/x/tools v0.0.0-20190619215442-4adf7a708c2d // indirect
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac // indirect
gopkg.in/yaml.v2 v2.2.2 // indirect
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190619215442-4adf7a708c2d h1:LQ06Vbju+Kwbcd94hb+6CgDsWoj/e7GOLPcYzHrG+iI=
golang.org/x/tools v0.0.0-20190619215442-4adf7a708c2d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac h1:MQEvx39qSf8vyrx3XRaOe+j1UDIzKwkYOVObRgGPVqI=
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
Expand Down

0 comments on commit 2a6239e

Please sign in to comment.