Skip to content

Instantly share code, notes, and snippets.

@parsley42
Last active March 27, 2018 11:56
Show Gist options
  • Save parsley42/d53a716fde35ff1603aec53738e1db07 to your computer and use it in GitHub Desktop.
Save parsley42/d53a716fde35ff1603aec53738e1db07 to your computer and use it in GitHub Desktop.
profiling
# Check on running go routines:
[parse@parse lnxjedi]$ go tool pprof http://localhost:8888/debug/pprof/goroutine
Fetching profile over HTTP from http://localhost:8888/debug/pprof/goroutine
Saved profile in /home/parse/pprof/pprof.bot.test.goroutine.008.pb.gz
File: bot.test
Type: goroutine
Time: Mar 25, 2018 at 12:13am (UTC)
Entering interactive mode (type "help" for commands, "o" for options)
(pprof) list lnxjedi
Total: 11
ROUTINE ======================== github.com/lnxjedi/gopherbot/bot.(*Robot).Say in /home/parse/go/src/github.com/lnxjedi/gopherbot/bot/robot.go
0 1 (flat, cum) 9.09% of Total
. . 241:// Say just sends a message to the user or channel
. . 242:func (r *Robot) Say(msg string) RetVal {
. . 243: if r.Channel == "" {
. . 244: return robot.SendProtocolUserMessage(r.User, msg, r.Format)
. . 245: }
. 1 246: return robot.SendProtocolChannelMessage(r.Channel, msg, r.Format)
. . 247:}
# Generate coverage report:
[parse@parse gopherbot]$ go test -v --tags 'test integration' -cover -race -coverprofile coverage.out -coverpkg ./... ./bot/
[parse@parse gopherbot]$ go tool cover -html=coverage.out -o coverage.html
@parsley42
Copy link
Author

Just a gist to help me remember how to list the goroutines for a running program with pprof enabled - I don't do this often enough to keep in working memory. ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment