Go程序性能分析pprof
来源:互联网 发布:小眼睛美女 知乎 编辑:程序博客网 时间:2024/05/23 20:54
from: Go程序性能分析pprof
参考:
http://blog.golang.org/profiling-go-programs
http://google-perftools.googlecode.com/svn/trunk/doc/cpuprofile.html
Go语言的pprof是Google C++ profiler的移植,所以用法也差不多。这里简要记录步骤如下:
1. 代码
要在Go语言中开启profiling,可以参考以下代码:
- import (
- "runtime/pprof" // 引用pprof package
- "os"
- )
- func main() {
- f, _ := os.Create("profile_file")
- pprof.StartCPUProfile(f) // 开始cpu profile,结果写到文件f中
- defer pprof.StopCPUProfile() // 结束profile
- ...
- }
2. 运行
运行程序,生成profile文件3. 分析
在命令行上执行:
go tool pprof [binary] [profile]进入pprof环境后,可以用help命令查看帮助信息
最常用的命令如top10,可以看最耗时的function
这里详细解释一下top命令的输出格式,例如:
14 2.1% 17.2% 58 8.7% std::_Rb_tree::find
各字段的含义依次是:
1. 采样点落在该函数中的次数
2. 采样点落在该函数中的百分比
3. 上一项的累积百分比
4. 采样点落在该函数,以及被它调用的函数中的总次数
5. 采样点落在该函数,以及被它调用的函数中的总次数百分比
6. 函数名
阅读全文
0 0
- Go程序性能分析pprof
- Go程序性能分析pprof
- go使用pprof做性能分析
- Go 程序的性能优化及 pprof 的使用
- 使用golang的pprof包对程序进行性能分析
- 【善用工具】程序性能分析Gperftools初探(libwind+pprof+Kcachegrind)
- [golang]pprof性能分析工具
- go pprof
- Golang性能调优(go-torch, go tool pprof)
- 使用go tool pprof分析内存泄漏、CPU消耗
- go tool pprof
- 一个Ip2long函数,通过调用go tool pprof分析,竟发现内存分配了3G
- fabric调试:go pprof查看内存
- Go程序实例分析
- go学习(九)——Go tool pprof之runtime/pprof 的使用
- go标准命令详解0.12 go tool pprof
- Go 程序的性能调试问题
- 程序数据库性能分析。
- elasticsearch client依赖包下载方法
- HTTP协议
- myeclipse中安装maven插件
- Storm学习笔记
- 文章标题
- Go程序性能分析pprof
- Eclipse/MyEclipse转IntelliJ IDEA完全攻略
- Xcode打包ipa的基本步骤(有证书和无证书)
- 关于如何避免操作(update、delete)mysql数据库时忘记添加where而导致全表修改或删除情况
- 动态规划中 用O(n)时间遍历数组
- Oracle SQL语句面试题二
- C++类的多重继承
- CentOS7 下 Python3.5.1安装过程
- innobackupex 远程备份官网