glob/bench.sh

33 lines
676 B
Bash
Raw Normal View History

2016-02-24 00:49:41 +03:00
#! /bin/bash
2019-02-06 23:59:37 +03:00
rnd=$(head -c4 </dev/urandom|xxd -p -u)
2019-02-06 23:51:47 +03:00
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:59:37 +03:00
filename=$(echo "$rnd-$1.bench" | tr "/" "_")
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:59:37 +03:00
benchcmp $3 "$rnd-${to}.bench" "$rnd-${current}.bench"