速查表之go pprof使用

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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值