pprof
pprof is a tool for visualization and analysis of profiling data
A Google tool for analyzing where a Go program spends time and memory, generating text reports and visual call graphs to help developers find and fix performance bottlenecks.
pprof is a tool from Google for analyzing how a program spends its time and resources while running. Developers use it to identify which parts of their code are slow or using more memory than expected. This kind of analysis is called profiling, and pprof is one of the most widely used tools for it in the Go programming language ecosystem, though it can also work with profiling data from other sources.
The tool reads a file containing a recorded profile, which is a snapshot of what the program was doing at many points during execution. From that data, pprof can generate several types of output. You can get a text report listing the slowest functions ranked by how much time they consumed. You can generate a visual graph, displayed as a web page or an image file, that shows which functions called which others and how much time each one took. There is also an interactive mode where you type commands to explore the data from the command line.
Profiles can come from a local file or be pulled directly from a running server over a network connection. Multiple profiles can be combined or compared against each other, which is useful for checking whether a code change made performance better or worse.
Installing pprof requires Go to be set up on your machine. The README provides the installation command. Optional integration with Graphviz, a graph drawing library, is needed for generating visual diagrams. Google notes that pprof is not an officially supported Google product, meaning it is maintained on a best-effort basis without formal support commitments.
Where it fits
- Profile a running Go HTTP server to identify which functions consume the most CPU or memory.
- Compare profiles taken before and after a code change to verify whether a performance fix actually improved speed.
- Generate a visual call graph from a recorded profile to understand execution flow and bottlenecks at a glance.