pprof进行golang程序性能分析
2024-10-15 16:42:10
一、导入包
import _ "net/http/pprof"
二、启动监控routine
go func() {
http.ListenAndServe("0.0.0.0:18080", nil)
}() 三、访问web服务
例:分析CPU占用情况
go tool pprof http://localhost:18080/debug/pprof/profile
(pprof) top10
Total: 2525 samples
298 11.8% 11.8% 345 13.7% runtime.mapaccess1_fast64
268 10.6% 22.4% 2124 84.1% main.FindLoops
251 9.9% 32.4% 451 17.9% scanblock
178 7.0% 39.4% 351 13.9% hash_insert
131 5.2% 44.6% 158 6.3% sweepspan
119 4.7% 49.3% 350 13.9% main.DFS
96 3.8% 53.1% 98 3.9% flushptrbuf
95 3.8% 56.9% 95 3.8% runtime.aeshash64
95 3.8% 60.6% 101 4.0% runtime.settype_flush
88 3.5% 64.1% 988 39.1% runtime.mallocgc 四、参考
// pprof 命令
https://blog.golang.org/profiling-go-programs
// web 上几项监控指标
https://golang.org/pkg/net/http/pprof/
最新文章
- 纯css实现模块阴影变色效果
- Mysql通信协议
- jQuery选择器和选取方法
- Android5.0常用颜色属性说明
- C++ Win32控制台应用程序捕捉关闭事件
- MongoDB安装,打开及增,删,改,查
- 自动备份多个MOSS站点集的脚本
- Mahout-Pearson correlation的实现
- ARMv8 Linux内核异常处理过程分析
- 记得有一个奇怪的ORA-04028: cannot generate diana for object
- git安装包解压后没有configure
- 3、调试AngularJs
- 字符串格式化:f-strings
- Swift5 语言指南(二) 版本兼容性
- 黄聪:多个wordpress网站(不同域名)共享用户数据的方法
- 线程系列07,使用lock语句块或Interlocked类型方法保证自增变量的数据同步
- 如何利用webmin在Linux主机中添加网站
- flask请求和应用上下文
- 【python】argparse学习(转)
- Arduino I2C + 温湿度传感器HTS221