go pprof 基本使用
https://go-zh.org/pkg/net/http/pprof/
全记录
【实践】WINDOWS下GOlang性能测试分析工具PProf&GO torch入门指导
"net/http"
_ "net/http/pprof"
go func() {
log.Log(http.ListenAndServe("0.0.0.0:8000", nil))
}()
go tool pprof -http=:8088 http://192.168.0.4:8000/debug/pprof/profile
go tool pprof -http=:8089 http://192.168.0.4:8000/debug/pprof/heap
go tool pprof -http=:8084 http://192.168.0.4:8000/debug/pprof/goroutine
访问任意一个端口,即可看下如下图(安装graphviz)
brew install graphviz / yum install graphviz / choco install graphviz /sudo apt install graphviz
参考 https://graphviz.org/download/
命令行模式
$ go tool pprof http://192.168.0.4:8000/debug/pprof/heap
$ top
Showing nodes accounting for 2284.30kB, 100% of 2284.30kB total
flat flat% sum% cum cum%
1762.94kB 77.18% 77.18% 1762.94kB 77.18% runtime/pprof.StartCPUProfile
521.37kB 22.82% 100% 521.37kB 22.82% encoding/xml.init
0 0% 100% 1762.94kB 77.18% net/http.(*ServeMux).ServeHTTP
0 0% 100% 1762.94kB 77.18% net/http.(*conn).serve
0 0% 100% 1762.94kB 77.18% net/http.HandlerFunc.ServeHTTP
0 0% 100% 1762.94kB 77.18% net/http.serverHandler.ServeHTTP
0 0% 100% 1762.94kB 77.18% net/http/pprof.Profile
0 0% 100% 521.37kB 22.82% runtime.doInit
0 0% 100% 521.37kB 22.82% runtime.main