当前位置: 首页 > news >正文

golang性能调试工具net/http/pprof

代码引入net/http/pprof:

package mainimport ("fmt""net/http"_ "net/http/pprof"
)func main() {go func() {fmt.Println(http.ListenAndServe(":9192", nil))}()
}

编译启动后,通过页面访问:

http://192.168.137.2:9192/debug/pprof/

分为以下项目:

Profile Descriptions:

  • allocs:

    A sampling of all past memory allocations
  • block:

    Stack traces that led to blocking on synchronization primitives
  • cmdline:

    The command line invocation of the current program
  • goroutine:

    Stack traces of all current goroutines. Use debug=2 as a query parameter to export in the same format as an unrecovered panic.
  • heap:

    A sampling of memory allocations of live objects. You can specify the gc GET parameter to run GC before taking the heap sample.
  • mutex:

    Stack traces of holders of contended mutexes
  • profile:

    CPU profile. You can specify the duration in the seconds GET parameter. After you get the profile file, use the go tool pprof command to investigate the profile.
  • threadcreate:

    Stack traces that led to the creation of new OS threads
  • trace:

    A trace of execution of the current program. You can specify the duration in the seconds GET parameter. After you get the trace file, use the go tool trace command to investigate the trace.

但是此种方式查看不够直观,可以通过go tool pprof工具生成动态图像查看:

yum install graphviz

查看内存分配:

go tool pprof -http=192.168.137.2:8000 http://127.0.0.1:9192/debug/pprof/allocs

查看CPU占用:

go tool pprof -http=192.168.137.2:8000 http://127.0.0.1:9192/debug/pprof/profile

本机防火墙开放8000端口,通过页面访问:

firewall-cmd --add-port=8000/tcp --permanent

firewall-cmd --reload

http://192.168.137.2:8000/ui/

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • 时序数据库如何选型?详细指标总结!
  • ubuntu如何彻底卸载android studio?
  • 掌握Python中的文件序列化:Json和Pickle模块解析
  • 笔记:Few-Shot Learning小样本分类问题 + 孪生网络 + 预训练与微调
  • Python面试整理-字典和集合的操作
  • Eureka——Spring Cloud中的服务注册与发现组件
  • python运维实战-ssh工具
  • 如何建设和维护数据仓库:深入指南
  • 开源的语音合成工具_ChatTTS_用法及资源
  • 农场驿站平台小程序的设计
  • 概率论原理精解【4】
  • 微信小程序数组绑定使用案例(一)
  • 会Excel就会sql?
  • 【操作系统】定时器(Timer)的实现
  • PY32F002B单片机 ISP 串口下载注意事项
  • [译] 理解数组在 PHP 内部的实现(给PHP开发者的PHP源码-第四部分)
  • 【108天】Java——《Head First Java》笔记(第1-4章)
  • Eureka 2.0 开源流产,真的对你影响很大吗?
  • JAVA SE 6 GC调优笔记
  • java第三方包学习之lombok
  • js作用域和this的理解
  • Linux编程学习笔记 | Linux IO学习[1] - 文件IO
  • Octave 入门
  • Python_OOP
  • SQLServer之索引简介
  • 技术发展面试
  • 快速体验 Sentinel 集群限流功能,只需简单几步
  • 离散点最小(凸)包围边界查找
  • 前端每日实战:70# 视频演示如何用纯 CSS 创作一只徘徊的果冻怪兽
  • 前端学习笔记之原型——一张图说明`prototype`和`__proto__`的区别
  • 入职第二天:使用koa搭建node server是种怎样的体验
  • 我从编程教室毕业
  • 浅谈sql中的in与not in,exists与not exists的区别
  • ​DB-Engines 12月数据库排名: PostgreSQL有望获得「2020年度数据库」荣誉?
  • "无招胜有招"nbsp;史上最全的互…
  • $.proxy和$.extend
  • (Redis使用系列) Springboot 在redis中使用BloomFilter布隆过滤器机制 六
  • (安卓)跳转应用市场APP详情页的方式
  • (八)Docker网络跨主机通讯vxlan和vlan
  • (附源码)springboot“微印象”在线打印预约系统 毕业设计 061642
  • (附源码)计算机毕业设计ssm电影分享网站
  • (一)、python程序--模拟电脑鼠走迷宫
  • (一)SpringBoot3---尚硅谷总结
  • (转) SpringBoot:使用spring-boot-devtools进行热部署以及不生效的问题解决
  • (转)http-server应用
  • (转贴)用VML开发工作流设计器 UCML.NET工作流管理系统
  • (自用)gtest单元测试
  • .ai域名是什么后缀?
  • .net mvc 获取url中controller和action
  • .NET 给NuGet包添加Readme
  • .Net 转战 Android 4.4 日常笔记(4)--按钮事件和国际化
  • .net和php怎么连接,php和apache之间如何连接
  • .net后端程序发布到nignx上,通过nginx访问
  • .NET设计模式(2):单件模式(Singleton Pattern)
  • .NET中的Exception处理(C#)