LeungGeorge / LeungGeorge.github.io

没有什么事儿是一句话讲不明白的。如果有,那就写篇博客!
https://leunggeorge.github.io/
1 stars 0 forks source link

golang 性能分析 #5

Open LeungGeorge opened 4 years ago

LeungGeorge commented 4 years ago

https://colobu.com/2017/03/02/a-short-survey-of-golang-pprof/ https://www.cnblogs.com/coder-886/p/7541843.html https://zhuanlan.zhihu.com/p/33528194 https://blog.csdn.net/ugg/article/details/46348815 http://www.bo56.com/download/gprof2dot.tar.gz https://www.cnblogs.com/ricklz/p/11262069.html https://www.cnblogs.com/landv/p/11274877.html#_label2 http://aibenlin.com/golang/2019/07/13/golang-pprof_application.html

LeungGeorge commented 4 years ago

go tool pprof -alloc_space http://ip:port/debug/pprof/heap (pprof) web (pprof) svg

用浏览器打开生成的 svg 文件

LeungGeorge commented 4 years ago

https://colobu.com/2017/03/02/a-short-survey-of-golang-pprof/ pprof 用法: 安装 如下工具,然后执行 最后的 go tool pprof xxx 命令(不带 web 进入命令行,可以自由生成各种格式:pdf、png、svg等等)。

$ brew install gperftools $ brew install graphviz

go tool pprof -web http://10.75.25.126:9091/debug/pprof/profile

image

LeungGeorge commented 4 years ago

火焰图 (Flame Graph) https://colobu.com/2017/03/02/a-short-survey-of-golang-pprof/ go-torch 用法: 1.安装 2.在 brendangregg/FlameGraph 目录下执行 go-torch,或者加 PATH

$ go get github.com/uber/go-torch $ git clone git@github.com:brendangregg/FlameGraph.git $ export PATH-$PATH:/path/to/FlameGraph

go-torch --file "torch.svg" --url http://localhost:6060

image

LeungGeorge commented 4 years ago

https://www.cnblogs.com/landv/p/11274877.html#_label2 1.分析指定包

(pprof) svg http

image