runtime/pprof

Package pprof

Overview

Package pprof writes runtime profiling data in the format expected by the pprof visualization tool.

Profiling a Go program

The first step to profiling a Go program is to enable profiling. Support for profiling benchmarks built with the standard testing package is built into go test. For example, the following command runs benchmarks in the current directory and writes the CPU and memory profiles to cpu.prof and mem.prof:

go test -cpuprofile cpu.prof -memprofile mem.prof -bench .

To add equivalent profiling support to a standalone program, add code like the following to your main f