Skip to content

Instantly share code, notes, and snippets.

@romainmenke
Last active August 26, 2017 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save romainmenke/95b3b8a67a8ffb2c81f99b99bc5c594a to your computer and use it in GitHub Desktop.
Save romainmenke/95b3b8a67a8ffb2c81f99b99bc5c594a to your computer and use it in GitHub Desktop.
#!/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