Golang 大杀器之性能剖析 PProf

2021-02-21  本文已影响0人  五岁小孩

Golang 大杀器之性能剖析 PProf

来源(转)

https://www.jianshu.com/p/4e4ff6be6af9

支持的使用模式:

* Report generation:报告生成

用途

使用

访问

go tool pprof http://localhost:6060/debug/pprof/profile?seconds=60

heap 分析

(2) go tool pprof http://localhost:6060/debug/pprof/heap?seconds=60

block分析

(3) go tool pprof http://localhost:6060/debug/pprof/block?seconds=60

协程分析

(4) go tool pprof http://localhost:6060/debug/pprof/goroutine?seconds=60

mutex 分析

(5) go tool pprof http://localhost:6060/debug/pprof/mutex?seconds=60


* flat:当前函数占用CPU的耗时

* flat%:当前函数占用CPU的耗时百分比

* sum%:给定函数累积使用 CPU 总比例

* cum:当前函数加上调用当前函数的函数占用CPU的总耗时

* cum%:当前函数加上调用当前函数的函数占用CPU的总耗时百分比

* -inuse_space:分析应用程序的常驻内存占用情况

* -alloc_objects:分析应用程序的内存临时分配情况

  

~~~json
$ go tool pprof http://localhost:6060/debug/pprof/heap
Fetching profile over HTTP from http://localhost:6060/debug/pprof/heap
Saved profile in /Users/eddycjy/pprof/pprof.alloc_objects.alloc_space.inuse_objects.inuse_space
.008.pb.gz
Type: inuse_space
Entering interactive mode (type "help" for commands, "o" for options)
(pprof) top
Showing nodes accounting for 837.48MB, 100% of 837.48MB total
      flat  flat%   sum%        cum   cum%
  837.48MB   100%   100%   837.48MB   100%  main.main.func1
   go tool pprof -http=":8081"  ew-iepms.exe http://localhost:6060/debug/pprof/block
   
   ## CPU
   go tool pprof -http=":8081"  ew-iepms.exe http://localhost:6060/debug/pprof/profile
   ## heap 分析
   (2) go tool pprof -http=":8081"  ew-iepms.exe http://localhost:6060/debug/pprof/heap
   ## block分析
   (3) go tool pprof -http=":8081"  ew-iepms.exe http://localhost:6060/debug/pprof/block
   ## 协程分析
   (4) go tool pprof -http=":8081"  ew-iepms.exe http://localhost:6060/debug/pprof/goroutine
   ## mutex 分析
   (5) go tool pprof -http=":8081"  ew-iepms.exe http://localhost:6060/debug/pprof/mutex

码字不易,还望各位哥哥姐姐们关注点赞支持一下

上一篇 下一篇

猜你喜欢

热点阅读