CPU Profiling with pprof
Collecting and visualizing CPU profiles
What is pprof?
net/http/pprof and the runtime/pprof package expose profiling data that shows where your program spends CPU time. The go tool pprof CLI analyses profiles.
HTTP pprof endpoint
Import _ "net/http/pprof" to register profiling endpoints under /debug/pprof/ on an existing HTTP server.
import _ "net/http/pprof"
go func() {
log.Println(http.ListenAndServe(":6060", nil))
}()All lessons in this course
- Writing Benchmarks with testing.B
- CPU Profiling with pprof
- Heap and Allocation Profiling
- Execution Tracing