From 9bf042f426d8a7d8ab1666485f548e9b22b52ed8 Mon Sep 17 00:00:00 2001 From: gobwas Date: Wed, 6 Feb 2019 23:51:47 +0300 Subject: [PATCH] wip --- bench.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/bench.sh b/bench.sh index c6e7de3..bce9595 100755 --- a/bench.sh +++ b/bench.sh @@ -1,18 +1,22 @@ #! /bin/bash +tmp=$(mktemp -d /tmp/globbench.XXXXXX) +echo "temp dir is $tmp"; + bench() { - if [[ -z $2 ]]; then - $2 = ".*" + local exp=".*" + if [[ ! -z $2 ]]; then + $exp = $2 fi - filename="/tmp/$1.bench" + filename="$tmp/$1.bench" if test -e "${filename}"; then echo "Already exists ${filename}" else backup=`git rev-parse --abbrev-ref HEAD` - git checkout $1 + git checkout "$1" echo -n "Creating ${filename}... " - go test ./... -run=NONE -bench=$2 > "${filename}" -benchmem + go test ./... -run=NONE -bench="$exp" > "${filename}" -benchmem echo "OK" git checkout ${backup} sleep 5 @@ -26,4 +30,4 @@ current=`git rev-parse --abbrev-ref HEAD` bench ${to} $2 bench ${current} $2 -benchcmp $3 "/tmp/${to}.bench" "/tmp/${current}.bench" +benchcmp $3 "$tmp/${to}.bench" "$tmp/${current}.bench"