glob/bench.sh

34 lines
679 B
Bash
Raw Normal View History

2016-02-24 00:49:41 +03:00
#! /bin/bash
2019-02-06 23:51:47 +03:00
tmp=$(mktemp -d /tmp/globbench.XXXXXX)
echo "temp dir is $tmp";
2016-02-24 00:49:41 +03:00
bench() {
2019-02-06 23:51:47 +03:00
local exp=".*"
if [[ ! -z $2 ]]; then
$exp = $2
2019-02-06 23:48:06 +03:00
fi
2019-02-06 23:51:47 +03:00
filename="$tmp/$1.bench"
2016-02-24 00:49:41 +03:00
if test -e "${filename}";
then
echo "Already exists ${filename}"
else
backup=`git rev-parse --abbrev-ref HEAD`
2019-02-06 23:51:47 +03:00
git checkout "$1"
2016-02-24 00:49:41 +03:00
echo -n "Creating ${filename}... "
2019-02-06 23:51:47 +03:00
go test ./... -run=NONE -bench="$exp" > "${filename}" -benchmem
2016-02-24 00:49:41 +03:00
echo "OK"
2016-02-24 13:51:14 +03:00
git checkout ${backup}
2016-02-24 23:25:01 +03:00
sleep 5
2016-02-24 00:49:41 +03:00
fi
}
to=$1
current=`git rev-parse --abbrev-ref HEAD`
bench ${to} $2
bench ${current} $2
2019-02-06 23:51:47 +03:00
benchcmp $3 "$tmp/${to}.bench" "$tmp/${current}.bench"