go pprof火焰图性能优化

August 16, 2022 默认分类

使用生成火焰图优化

获取cpuprofile

获取最近10秒程序运行的cpuprofile,-seconds参数不填默认为30。

go tool pprof http://127.0.0.1:8080/debug/pprof/profile -seconds 10

等10s后会生成一个: pprof.samples.cpu.001.pb.gz文件

生成火焰图

go tool pprof -http=:8081 ~/pprof/pprof.samples.cpu.001.pb.gz

其中-http=:8081会启动一个http服务,端口为8081, 浏览器打开 localhost:8081

添加新评论

本站支持IPv6访问