Last active
August 26, 2017 18:25
-
-
Save romainmenke/95b3b8a67a8ffb2c81f99b99bc5c594a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
# add *.bench to .gitignore | |
trap 'kill -HUP 0' EXIT; | |
currentBranch=$(git rev-parse --abbrev-ref HEAD) | |
echo "bench current state" | |
go test -run=NONE -bench=. ./... > new.bench | |
git diff-index --quiet HEAD -- && | |
{ | |
echo "checkout master" | |
git checkout master | |
}; | |
git diff-index --quiet HEAD -- || | |
{ | |
echo "stash and checkout master" | |
git stash | |
stashed=true | |
git checkout master | |
}; | |
echo "bench master" | |
go test -run=NONE -bench=. ./... > old.bench | |
echo "go back to current state" | |
git checkout $currentBranch | |
if [ "$stashed" = true ]; then | |
echo "pop stash" | |
git stash pop | |
fi | |
benchcmp old.bench new.bench |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment