go-torch
安装FlameGraph:
- git clone https://github.com/brendangregg/FlameGraph.git
- 将FlameGraph/flamegraph.pl 加入环境变量$PATH
- flamegraph.pl -h 测试
安装go-torch:
1. go get -v github.com/uber/go-torch
修改代码:
1. http 调用:import _ “net/http/pprof”
2. Gin 调用:import "github.com/DeanThompson/ginpprof" r := gin.Default() ginpprof.Wrap(r)
build && run
test:
go-torch -u http://10.8.163.167:6789/ -t 30
火焰图的y轴表示cpu调用方法的先后,x轴表示在每个采样调用时间内,方法所占的时间百分比,越宽代表占据cpu时间越多