What is the meaning of "flat" and "cum" in golang pprof output

blov · · 817 次点击

<p>New to golang pprof. What is the meaning of flat, cum in pprof?</p> <hr/>**评论：**<br/><br/>GregMartinez: <pre><p>Flat is duration spent on given a function and cum is cumulative of current function plus calls above it.</p></pre>YuchenLiu1993: <pre><p>If a() call b() call ( c() and d() ) , c() takes 1s to execute and d() takes 2s so &#34;cum&#34; of b() is 1+2=3s?</p> <p>But how to calculate flat of b() ?</p></pre>GregMartinez: <pre><p>Correct, cumulative of b would be c + d. Flat would be time directly in b. It&#39;s possible that flat and cumulative are the same.</p></pre>YuchenLiu1993: <pre><p>So &#34;flat&#34; is always greater equal than &#34;cum&#34;?</p></pre>fishywang: <pre><p>No. Assuming what in b() is:</p> <pre><code>c() // takes 1s do something directly // takes 3s d() // takes 2s </code></pre> <p>then cum of b() would be 6s, and flat of b() would be 3s (assuming that the &#34;do something directly&#34; part does not have function calls).</p></pre>YuchenLiu1993: <pre><p>Thank you for correcting my fault! I get it now!</p></pre>YuchenLiu1993: <pre><p>Thanks! I get it now!</p></pre>

0 回复

• 请尽量让自己的回复能够对别人有帮助
• 支持 Markdown 格式, **粗体**、~~删除线~~、``单行代码``
• 支持 @ 本站用户；支持表情（输入 : 提示），见 Emoji cheat sheet
• 图片支持拖拽、截图粘贴等方式上传