0Pricing
Go Academy · Lesson

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

  1. Writing Benchmarks with testing.B
  2. CPU Profiling with pprof
  3. Heap and Allocation Profiling
  4. Execution Tracing
← Back to Go Academy