pprof是个神马玩意儿?
pprof - manual page for pprof (part of gperftools)
是gperftools工具的一部分
gperftools又是啥?
These tools are for use by developers so that they can create more robust applications. Especially of use to those developing multi-threaded applications in C++ with templates. Includes TCMalloc, heap-checker, heap-profiler and cpu-profiler.
一个性能分析的工具,可以查看堆栈、cpu信息等等。
在golang中如何使用呢?下面就来看看。 1. 在一个httpserver中,只需要一行代码
2.编译运行这个程序
go build trace_example.go
./trace_example 3. 通过浏览器访问
http://localhost:6060/debug/pprof/
能够查看到程序的overview 4.你也可以通过终端命令查看
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