golang pprof

基本路径:/debug/pprof/

支持的分析类型:

cpu(CPU Profiling) : HOST/debug/pprof/profile,默认进行 30s 的 CPU Profiling,得到一个分析用的 profile 文件

block(Block Profiling) :HOST/debug/pprof/block,查看导致阻塞同步的堆栈跟踪

goroutine(Goroutine Profiling) :HOST/debug/pprof/goroutine,查看当前所有运行的goroutines 堆栈跟踪

heap(Memory Profiling): HOST/debug/pprof/heap,查看活动对象的内存分配情况

mutex(Mutex Profiling) :HOST/debug/pprof/mutex,查看导致互斥锁的竞争持有者的堆栈跟踪

threadcreate :HOST/debug/pprof/threadcreate,查看创建新OS线程的堆栈跟踪

生成分析文件:
go tool pprof --text http://localhost:8080/debug/pprof/profile

启动 pprof web可视化界面

方法一 :需要采集到的结果文件

go tool pprof -http=:8080 cpu.prof

方法二:需要采集到的结果文件

go tool pprof cpu.prof
web

最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容