分享
51.Golang FlameGraph(火焰图)
更多精彩内容【实践】WINDOWS下GOlang性能测试分析工具PProf&GO torch入门指导笔名辉哥Golang FlameGraph(火焰图)zr_hebogo性能优化初级赛亚人golang 使用pprof和go-torch做性能分析 -- W · · 1154 次点击 · · 开始浏览这是一个创建于 的文章,其中的信息可能已经有所发展或是发生改变。
1.安装组件
- 安装go-torch
go get github.com/uber/go-torch - 安装 FlameGraph
cd $WORK_PATH && git clone https://gitee.com/mirrors/FlameGraph.git
export PATH=$PATH:$WORK_PATH/FlameGraph - 安装graphviz
yum install graphviz(CentOS, Redhat)
2.代码修改
package main
import (
"net/http"
"net/http/pprof"
)
func main() {
// 主函数中添加
go func() {
http.HandleFunc("/debug/pprof/block", pprof.Index)
http.HandleFunc("/debug/pprof/goroutine", pprof.Index)
http.HandleFunc("/debug/pprof/heap", pprof.Index)
http.HandleFunc("/debug/pprof/threadcreate", pprof.Index)
http.ListenAndServe("0.0.0.0:8888", nil)
}()
var finishWaiter chan int
<-finishWaiter
}
3.查看结果
运行上述程序后,使用如下命令生成CPU火焰图:
go-torch -u http://localhost:8888/debug/pprof/ -p > profile-local.svg
有疑问加站长微信联系(非本文作者)
本文来自:简书
感谢作者:更多精彩内容【实践】WINDOWS下GOlang性能测试分析工具PProf&GO torch入门指导笔名辉哥Golang FlameGraph(火焰图)zr_hebogo性能优化初级赛亚人golang 使用pprof和go-torch做性能分析 -- W
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
关注微信1154 次点击
添加一条新回复
(您需要 后才能回复 没有账号 ?)
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码` - 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传
收入到我管理的专栏 新建专栏
1.安装组件
- 安装go-torch
go get github.com/uber/go-torch - 安装 FlameGraph
cd $WORK_PATH && git clone https://gitee.com/mirrors/FlameGraph.git
export PATH=$PATH:$WORK_PATH/FlameGraph - 安装graphviz
yum install graphviz(CentOS, Redhat)
2.代码修改
package main
import (
"net/http"
"net/http/pprof"
)
func main() {
// 主函数中添加
go func() {
http.HandleFunc("/debug/pprof/block", pprof.Index)
http.HandleFunc("/debug/pprof/goroutine", pprof.Index)
http.HandleFunc("/debug/pprof/heap", pprof.Index)
http.HandleFunc("/debug/pprof/threadcreate", pprof.Index)
http.ListenAndServe("0.0.0.0:8888", nil)
}()
var finishWaiter chan int
<-finishWaiter
}
3.查看结果
运行上述程序后,使用如下命令生成CPU火焰图:
go-torch -u http://localhost:8888/debug/pprof/ -p > profile-local.svg