Go: Performance Profiling
Quick guide how to enable performance profiling in golang.
Guide
Install the graphviz
brew install graphviz
Add pprof server in the main.go
func main() {
// PPROF
go func() {
log.Printf("Starting Server! \t Go to http://localhost:6060/debug/pprof/\n")
err := http.ListenAndServe("localhost:6060", nil)
if err != nil {
log.Printf("Failed to start the server! Error: %v", err)
}
}()
}
After running a program launch pprof in http mode and bind it to :8000
port.
go tool pprof -http=":8000" http://localhost:6060/debug/pprof/allocs