Documentation ¶
Overview ¶
Package pprof is a fork of net/http/pprof modified to communicate over a unix socket.
Changes from the original version ¶
- This fork does not automatically register itself with the default net/http ServeMux.
- To start the pprof handler, see the Start method in socket.go.
- For compatability with Go 1.2.1, support for obtaining trace data has been removed.
---------------------------------------------------------------
Package pprof serves via its HTTP server runtime profiling data in the format expected by the pprof visualization tool. For more information about pprof, see http://code.google.com/p/google-perftools/.
The package is typically only imported for the side effect of registering its HTTP handlers. The handled paths all begin with /debug/pprof/.
To use pprof, link this package into your program:
import _ "net/http/pprof"
If your application is not already running an http server, you need to start one. Add "net/http" and "log" to your imports and the following code to your main function:
go func() { log.Println(http.ListenAndServe("localhost:6060", nil)) }()
Then use the pprof tool to look at the heap profile:
go tool pprof http://localhost:6060/debug/pprof/heap
Or to look at a 30-second CPU profile:
go tool pprof http://localhost:6060/debug/pprof/profile
Or to look at the goroutine blocking profile:
go tool pprof http://localhost:6060/debug/pprof/block
To view all available profiles, open http://localhost:6060/debug/pprof/ in your browser.
For a study of the facility in action, visit
https://blog.golang.org/2011/06/profiling-go-programs.html
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cmdline ¶
func Cmdline(w http.ResponseWriter, r *http.Request)
Cmdline responds with the running program's command line, with arguments separated by NUL bytes. The package initialization registers it as /debug/pprof/cmdline.
func Index ¶
func Index(w http.ResponseWriter, r *http.Request)
Index responds with the pprof-formatted profile named by the request. For example, "/debug/pprof/heap" serves the "heap" profile. Index responds to a request for "/debug/pprof/" with an HTML page listing the available profiles.
Types ¶
This section is empty.