分享
  1. 首页
  2. 文章

pprof进行golang程序性能分析

gm-201705 · · 1393 次点击 · · 开始浏览
这是一个创建于 的文章,其中的信息可能已经有所发展或是发生改变。

一、导入包

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/

有疑问加站长微信联系(非本文作者)

本文来自:博客园

感谢作者:gm-201705

查看原文:pprof进行golang程序性能分析

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

关注微信
1393 次点击
暂无回复
添加一条新回复 (您需要 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传

用户登录

没有账号?注册
(追記) (追記ここまで)

今日阅读排行

    加载中
(追記) (追記ここまで)

一周阅读排行

    加载中

关注我

  • 扫码关注领全套学习资料 关注微信公众号
  • 加入 QQ 群:
    • 192706294(已满)
    • 731990104(已满)
    • 798786647(已满)
    • 729884609(已满)
    • 977810755(已满)
    • 815126783(已满)
    • 812540095(已满)
    • 1006366459(已满)
    • 692541889

  • 关注微信公众号
  • 加入微信群:liuxiaoyan-s,备注入群
  • 也欢迎加入知识星球 Go粉丝们(免费)

给该专栏投稿 写篇新文章

每篇文章有总共有 5 次投稿机会

收入到我管理的专栏 新建专栏