Last active
June 4, 2024 23:21
-
-
Save pojntfx/389c52d06086b89d417dd8558b69b063 to your computer and use it in GitHub Desktop.
Use `pprof` to profile a Go application
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
import _ "net/http/pprof" | |
// ... | |
go func() { | |
log.Println(http.ListenAndServe("localhost:6060", nil)) | |
}() |
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 | |
# CPU: | |
go tool pprof -http=localhost:8080 localhost:6060 # Will collect samples for ~10s | |
# Memory: | |
go tool pprof -http=localhost:8080 localhost:6060/debug/pprof/heap |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment