We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 957d13a commit a2fcb5fCopy full SHA for a2fcb5f
etc/profile-test.sh
@@ -0,0 +1,33 @@
1
+#!/usr/bin/env bash
2
+# Convenience wrapper for profiling and tracing Go tests.
3
+set -eu
4
+
5
+# Set the prompt for the select menu.
6
+PS3="Choose a profile type: "
7
8
+options=("cpu" "mem" "block" "mutex" "trace")
9
10
+select choice in "${options[@]}"
11
+do
12
+ case $choice in
13
+ "cpu" | "mem" | "block" | "mutex")
14
+ tmpfile=$(mktemp)
15
+ echo "Writing $choice profile to $tmpfile"
16
17
+ go test -${choice}profile ${tmpfile} "$@"
18
+ go tool pprof -http=: ${tmpfile}
19
+ break
20
+ ;;
21
+ "trace")
22
23
+ echo "Writing trace to $tmpfile"
24
25
+ go test -trace ${tmpfile} "$@"
26
+ go tool trace ${tmpfile}
27
28
29
+ *)
30
+ echo "Invalid option. Please try again."
31
32
+ esac
33
+done
0 commit comments