README.md
1 [![Build Status](https://travis-ci.org/google/pprof.svg?branch=master)](https://travis-ci.org/google/pprof)
2 [![codecov](https://codecov.io/gh/google/pprof/graph/badge.svg)](https://codecov.io/gh/google/pprof)
3
4 # Introduction
5
6 pprof is a tool for visualization and analysis of profiling data.
7
8 pprof reads a collection of profiling samples in profile.proto format and
9 generates reports to visualize and help analyze the data. It can generate both
10 text and graphical reports (through the use of the dot visualization package).
11
12 profile.proto is a protocol buffer that describes a set of callstacks
13 and symbolization information. A common usage is to represent a set of
14 sampled callstacks from statistical profiling. The format is
15 described on the [proto/profile.proto](./proto/profile.proto) file. For details on protocol
16 buffers, see https://developers.google.com/protocol-buffers
17
18 Profiles can be read from a local file, or over http. Multiple
19 profiles of the same type can be aggregated or compared.
20
21 If the profile samples contain machine addresses, pprof can symbolize
22 them through the use of the native binutils tools (addr2line and nm).
23
24 **This is not an official Google product.**
25
26 # Building pprof
27
28 Prerequisites:
29
30 - Go development kit. Requires Go 1.7 or newer.
31 Follow [these instructions](http://golang.org/doc/code.html) to install the
32 go tool and set up GOPATH.
33
34 - Graphviz: http://www.graphviz.org/
35 Optional, used to generate graphic visualizations of profiles
36
37 To build and install it, use the `go get` tool.
38
39 go get github.com/google/pprof
40
41 Remember to set GOPATH to the directory where you want pprof to be
42 installed. The binary will be in `$GOPATH/bin` and the sources under
43 `$GOPATH/src/github.com/google/pprof`.
44
45 # Basic usage
46
47 pprof can read a profile from a file or directly from a server via http.
48 Specify the profile input(s) in the command line, and use options to
49 indicate how to format the report.
50
51 ## Generate a text report of the profile, sorted by hotness:
52
53 ```
54 % pprof -top [main_binary] profile.pb.gz
55 Where
56 main_binary: Local path to the main program binary, to enable symbolization
57 profile.pb.gz: Local path to the profile in a compressed protobuf, or
58 URL to the http service that serves a profile.
59 ```
60
61 ## Generate a graph in an SVG file, and open it with a web browser:
62
63 ```
64 pprof -web [main_binary] profile.pb.gz
65 ```
66
67 ## Run pprof on interactive mode:
68
69 If no output formatting option is specified, pprof runs on interactive mode,
70 where reads the profile and accepts interactive commands for visualization and
71 refinement of the profile.
72
73 ```
74 pprof [main_binary] profile.pb.gz
75
76 This will open a simple shell that takes pprof commands to generate reports.
77 Type 'help' for available commands/options.
78 ```
79
80 ## Run pprof via a web interface
81
82 If the `-http` flag is specified, pprof starts a web server at
83 the specified host:port that provides an interactive web-based interface to pprof.
84 Host is optional, and is "localhost" by default. Port is optional, and is a
85 random available port by default. `-http=":"` starts a server locally at
86 a random port.
87
88 ```
89 pprof -http=[host]:[port] [main_binary] profile.pb.gz
90 ```
91
92 The preceding command should automatically open your web browser at
93 the right page; if not, you can manually visit the specified port in
94 your web browser.
95
96 ## Using pprof with Linux Perf
97
98 pprof can read `perf.data` files generated by the
99 [Linux perf](https://perf.wiki.kernel.org/index.php/Main_Page) tool by using the
100 `perf_to_profile` program from the
101 [perf_data_converter](https://github.com/google/perf_data_converter) package.
102
103 ## Further documentation
104
105 See [doc/pprof.md](doc/pprof.md) for more detailed end-user documentation.
106
107 See [doc/developer/pprof.dev.md](doc/developer/pprof.dev.md) for developer documentation.
108
109 See [doc/developer/profile.proto.md](doc/developer/profile.proto.md) for a description of the profile.proto format.
110