-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathperfcheck
executable file
·73 lines (59 loc) · 1.76 KB
/
perfcheck
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
GO_PACKAGE=github.com/jumptrading/influx-spout
REFERENCE_REVISION=${REFERENCE_REVISION:-4d69bb7cd5a8dd80f33a54d9a4a43c5d05ac1e29}
echo "Comparing working tree against $REFERENCE_REVISION"
fatal() {
echo $1
exit 1
}
title() {
echo ">>>> $1"
}
capture_benchmarks() {
test_sizes=$1
output=$2
go test -tags="$test_sizes" -run='^$' -bench=. $(go list ./... | grep -v vendor) &> $output
if [[ $? -ne 0 ]]; then
cat $output
exit 1
fi
}
# Validate test sizes
test_sizes=$@
if [[ $test_sizes == "" ]]; then
fatal "at least one size of tests must be selected ('small', 'medium' or 'large')"
fi
for test_size in $test_sizes; do
case $test_size in
small) ;; medium) ;; large) ;;
*) fatal "invalid test size (value must be 'small', 'medium' or 'large')" ;;
esac
done
out_dir=$PWD
packages= current_bench_output="$out_dir/current.bench"
reference_bench_output="$out_dir/reference.bench"
title "Building benchcheck tool"
go build -o benchcheck/benchcheck ./benchcheck || exit 1
title "Running current benchmarks"
capture_benchmarks "$test_sizes" $current_bench_output
title "Setting up reference branch"
# Create a temporary GOPATH which gets removed on exit.
tempdir=`mktemp -d`
function cleanup() {
rm -rf $tempdir
}
trap cleanup EXIT
# Clone the repo into the temporary GOPATH
set -e
export GOPATH=$tempdir
clone_dir=$GOPATH/src/$GO_PACKAGE
echo "Cloning to $clone_dir"
git clone --quiet . $clone_dir
pushd $clone_dir > /dev/null
git checkout --quiet -b perfcheck $REFERENCE_REVISION
set +e
title "Running reference benchmarks"
capture_benchmarks "$test_sizes" $reference_bench_output
title "Comparing benchmarks"
popd > /dev/null
exec benchcheck/benchcheck $reference_bench_output $current_bench_output