pprof命令总结

pprof命令总结,第1张

概述启用pprof分析import("net/http"_"net/http/pprof")funcpprof()error{iferr:=http.ListenAndServe("0.0.0.0:8080",nil);err!=nil{returnerr}returnnil}funcmain(){gopprof() 启用pprof分析
import (    "net/http"    _ "net/http/pprof")func pprof() error {    if err := http.ListenAndServe("0.0.0.0:8080", nil); err != nil {        return err    }    return nil}func main() {    go pprof()    // order codes}
获取诊断报告进行分析

直接访问 localhost:8080/deBUG/pprof 可以看到能获取到的诊断报告

诊断报告类型备注
allocs内存分配采样
block导致阻塞的的同步语句堆栈信息, 但需要使用runtime.SetBlockProfileRate(1)开启
cmdline进程启动的命令行参数
goroutine当前所有goroutine的堆栈信息
heap当前活动的对象内存分配采样
mutex持有锁的堆栈信息
profilecpu的占用信息
threadcreate导致 *** 作系统创建新增的线程的堆栈信息
trace当前程序执行的trace
分析cpu占用
go tool pprof --http=0.0.0.0:8081 --seconds=10 localhost:8080/deBUG/pprof/profile
分析内存占用
go tool pprof --http=0.0.0.0:8081 localhost:8080/deBUG/pprof/heap
go tool pprof --http=0.0.0.0:8081 localhost:8080/deBUG/pprof/allocs
查看trace信息
wget -O trace.out localhost:8080/deBUG/pprof/trace
go tool trace --http=:8081 trace.out
总结

以上是内存溢出为你收集整理的pprof命令总结全部内容,希望文章能够帮你解决pprof命令总结所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1238930.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-06
下一篇 2022-06-06

发表评论

登录后才能评论

评论列表(0条)

保存