Documentation ¶
Overview ¶
Copyright 2016 Wenhui Shen <www.webx.top> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
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
Or to collect a 5-second execution trace:
wget http://localhost:6060/debug/pprof/trace?seconds=5
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 ¶
- Variables
- func BlockHandler() echo.HandlerFunc
- func Cmdline(e echo.Context)
- func CmdlineHandler() echo.HandlerFunc
- func GoroutineHandler() echo.HandlerFunc
- func Handler(name string) handler
- func HeapHandler() echo.HandlerFunc
- func Index(e echo.Context)
- func IndexHandler() echo.HandlerFunc
- func Profile(e echo.Context)
- func ProfileHandler() echo.HandlerFunc
- func Symbol(e echo.Context)
- func SymbolHandler() echo.HandlerFunc
- func ThreadCreateHandler() echo.HandlerFunc
- func Trace(e echo.Context)
- func TraceHandler() echo.HandlerFunc
- func Wrap(router *echo.Echo)
Constants ¶
This section is empty.
Variables ¶
var Wrapper = Wrap
Wrapper make sure we are backward compatible
Functions ¶
func BlockHandler ¶
func BlockHandler() echo.HandlerFunc
BlockHandler will pass the call from /debug/pprof/block to pprof
func Cmdline ¶
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 CmdlineHandler ¶
func CmdlineHandler() echo.HandlerFunc
CmdlineHandler will pass the call from /debug/pprof/cmdline to pprof
func GoroutineHandler ¶
func GoroutineHandler() echo.HandlerFunc
GoroutineHandler will pass the call from /debug/pprof/goroutine to pprof
func Handler ¶
func Handler(name string) handler
Handler returns an HTTP handler that serves the named profile.
func HeapHandler ¶
func HeapHandler() echo.HandlerFunc
HeapHandler will pass the call from /debug/pprof/heap to pprof
func Index ¶
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.
func IndexHandler ¶
func IndexHandler() echo.HandlerFunc
IndexHandler will pass the call from /debug/pprof to pprof
func Profile ¶
Profile responds with the pprof-formatted cpu profile. The package initialization registers it as /debug/pprof/profile.
func ProfileHandler ¶
func ProfileHandler() echo.HandlerFunc
ProfileHandler will pass the call from /debug/pprof/profile to pprof
func Symbol ¶
Symbol looks up the program counters listed in the request, responding with a table mapping program counters to function names. The package initialization registers it as /debug/pprof/symbol.
func SymbolHandler ¶
func SymbolHandler() echo.HandlerFunc
SymbolHandler will pass the call from /debug/pprof/symbol to pprof
func ThreadCreateHandler ¶
func ThreadCreateHandler() echo.HandlerFunc
ThreadCreateHandler will pass the call from /debug/pprof/threadcreate to pprof
func Trace ¶
Trace responds with the execution trace in binary form. Tracing lasts for duration specified in seconds GET parameter, or for 1 second if not specified. The package initialization registers it as /debug/pprof/trace.
func TraceHandler ¶
func TraceHandler() echo.HandlerFunc
TraceHandler will pass the call from /debug/pprof/trace to pprof
Types ¶
This section is empty.