我正在尝试在我的程序中使用pprof,然而,我得到的结果与我读到的文章略有不同(链接如下)。在我的结果中,我得到了这样的表:
(pprof) top10
1.65s of 1.72s total (95.93%)
Showing top 10 nodes out of 114 (cum >= 0.01s)
flat flat% sum% cum cum%
1.19s 69.19% 69.19% 1.20s 69.77% syscall.Syscall
0.16s 9.30% 78.49% 0.16s 9.30% runtime._ExternalCode这些列是什么:flat flat% sum% cum cum%
我正在读的文章:https://software.intel.com/en-us/blogs/2014/05/10/debugging-performance-issues-in-go-programs http://blog.golang.org/profiling-go-programs
发布于 2019-07-04 14:51:42
扁平和最高
假设有一个函数foo,它由3个函数和一个直接操作组成。
func foo(){
a() step1
b() step2
do something directly. step3
c() step4
}想象一下,当您调用函数foo时,需要6秒,时间分布如下。
func foo(){
a() // step1 takes 1s
b() // step2 takes 1s
do something directly. // step3 takes 3s
c() // step4 takes 1s
}在step3.
cum上花费的时间将是foo的总执行时间,其中包含子函数调用和直接操作。(cum = step1+ step2+ step3+ step4)总和%
当您在pprof console中运行top时,每一行输出都代表在特定功能上花费的时间。Sum%表示前面的行花费了多少时间/内存。
为了解释这个指标,我选择了另一个包含更多行的示例。第4行的sum%为45.17%。它是这样计算出来的:
line1 19.33%
line2 13.27%
line3 6.60%
line4 5.97%
-----------
sum% 45.17%

sum%的应用
sum%可以帮助你快速识别大石头。以下是内存分配报告的另一个示例。
您可以看到,前四个函数消耗了91.06%的内存。如果我想做一些性能调优,我应该专注于前四个函数。fourth下面的所有函数都可以忽略。

参考文献
Reddit: What is the meaning of "flat" and "cum" in golang pprof output
发布于 2017-07-22 03:52:46
我知道我会因为这个而受到抨击,但是看看GopherCon的演讲;,one such example on interpretation is here,还有一个来自Uber about pprof的演讲。
还有一篇Profiling Go Programs博客文章。
https://stackoverflow.com/questions/32571396
复制相似问题