Karan Sharma

Profiling Golang Applications with pprof

1 minutes (148 words)

🔗Creating a profile

To profile Golang applications, pprof package is widely used. There’s a nice wrapper around it https://github.com/pkg/profile which allows you to just drop one line in your application and start generating profiles:


package main

func main() {

  defer profile.Start(profile.ProfilePath("."), profile.NoShutdownHook).Stop()

  // rest of your application
}

🔗Visualizing

go tool pprof -http=":8000" ./cpu.pprof

This allows you to visualize the pprof file in Graphviz and the more helpful Flamegraph visualizations.

Tags: #Golang #Profiling #Performance