Skip to content

Instantly share code, notes, and snippets.

@sdboyer
Created October 30, 2017 01:57
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sdboyer/2c9a2a92e6a11638dbd49631e947d8b5 to your computer and use it in GitHub Desktop.
Save sdboyer/2c9a2a92e6a11638dbd49631e947d8b5 to your computer and use it in GitHub Desktop.
Figure out which of your go (sub)tests are slow
# This will sort go test -v output in ascending order of time to complete the test
$ go test -v | sed -n 's#.*PASS: \([^ ]*\) (\([0-9]*\.[0-9]\{2\}\)s)#\2 \1#p' | sort -g
# Add this to e.g. ~/.bashrc, ~/.zshrc, then you can pipe to it: `go test -v | goslowtests`
function goslowtests {
sed -n 's#.*PASS: \([^ ]*\) (\([0-9]*\.[0-9]\{2\}\)s)#\2 \1#p' | sort -g
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment