Last active
August 24, 2018 14:23
-
-
Save adampolar/a41540e50e0173049b0e8122ee3faf93 to your computer and use it in GitHub Desktop.
Quick and dirty shell script to get some pngs from the go test tool and pprof
This file contains 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 | |
#get file name | |
number=0 | |
suffix="$( printf -- '-%02d' "$number" )" | |
while test -e "memprofile$suffix.png" || test -e "cpuprofile$suffix.png" || test -e timeprofile$suffix.txt; do | |
((++number)) | |
suffix="$( printf -- '-%02d' "$number" )" | |
done | |
testregex=${1:-.} | |
go test -bench=$testregex -memprofile mem.out -cpuprofile cpu.out > timeprofile$suffix.txt | |
if [ -e cpu.out ] | |
then | |
go tool pprof -png cpu.out > cpuprofile$suffix.png | |
fi | |
if [ -e mem.out ] | |
then | |
go tool pprof -png -alloc_space mem.out > memprofile$suffix.png | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment