File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 22# Convenience wrapper for profiling and tracing Go tests.
33set -eu
44
5- # Set the prompt for the select menu.
6- PS3=" Choose a profile type: "
5+ # Create a temporary file to store the profile or trace data. Trap the exit
6+ # signals to clean it up after the script exits (typically via Ctrl-C).
7+ tmpfile=$( mktemp)
8+ trap ' rm -f "$tmpfile"' EXIT INT TERM
79
10+ # Set the prompt and options for the select menu.
11+ PS3=" Choose a profile type: "
812options=(" cpu" " mem" " block" " mutex" " trace" )
913
1014select choice in " ${options[@]} "
1115do
1216 case $choice in
1317 " cpu" | " mem" | " block" | " mutex" )
14- tmpfile=$( mktemp)
1518 echo " Writing $choice profile to $tmpfile "
1619
1720 go test -${choice} profile ${tmpfile} " $@ "
1821 go tool pprof -http=: ${tmpfile}
1922 break
2023 ;;
2124 " trace" )
22- tmpfile=$( mktemp)
2325 echo " Writing trace to $tmpfile "
2426
2527 go test -trace ${tmpfile} " $@ "
You can’t perform that action at this time.
0 commit comments