来查看正在使用的对象较多的个函数入口 top查看

 go tool pprof --inuse_space http://127.0.0.1:8182/debug/pprof/heap

来查看累积分配内存较多的一些函数调用 top查看

 go tool pprof --alloc_objects http://127.0.0.1:8182/debug/pprof/heap

查看25S内CPU的使用情况,分析函数耗时 top查看

go tool pprof --seconds 25 http://localhost:9090/debug/pprof/profile 

查看svg数据(先安装graphviz)

sudo apt-get install graphviz

go tool pprof --seconds 25 http://localhost:9090/debug/pprof/profile 

//输出
Fetching profile over HTTP from http://localhost:9090/debug/pprof/profile profile?seconds=25
Please wait... (25s)
Saved profile in /home/howie/pprof/pprof.test.samples.cpu.004.pb.gz
File: test
Type: cpu
Time: Apr 26, 2019 at 3:32pm (CST)
Duration: 25.08s, Total samples = 20.88s (83.24%)
Entering interactive mode (type "help" for commands, "o" for options)
(pprof) web
//输入web 就可以在浏览器中看svg图了

当我们不明确这些调用时是被哪些函数引起的时,我们可以输入top -cum来查找,-cum的意思就是,将函数调用关系 中的数据进行累积,比如A函数调用的B函数,则B函数中的内存分配量也会累积到A上面,这样就可以很容易的找出调用链。

使用go-wrk工具进行试压,go-wrk的安装请前往github官网https://github.com/adjust/go-wrk,只要把代码clone下来go build一下即可。

联系 QQ: 3355168235