title: How to get a function-duration breakdown in go (profiling)
body: <p><strong>Update (Jan 24, 2019):</strong> </p>
  
  <p>This question was asked 4 years ago about Go 1.4 (and is still getting views). Profiling with pprof has changed dramatically since then.</p>
  
  <p><strong>Original Question:</strong></p>
  
  <p>I'm trying to profile a go martini based server I wrote, I want to profile a single request, and get the complete breakdown of the function with their runtime duration.
  I tried playing around with both <code>runtime/pprof</code> and <code>net/http/pprof</code> but the output looks like this:</p>
  
  <pre><code>Total: 3 samples
         1  33.3%  33.3%        1  33.3% ExternalCode
         1  33.3%  66.7%        1  33.3% runtime.futex
         1  33.3% 100.0%        2  66.7% syscall.Syscall
  </code></pre>
  
  <p>The web view is not very helpful either.</p>
  
  <p>We regularly profile another program, and the output seems to be what I need:</p>
  
  <pre><code>20ms of 20ms total (  100%)
        flat  flat%  sum%        cum  cum%
        10ms 50.00% 50.00%     10ms 50.00%  runtime.duffcopy
        10ms 50.00%   100%     10ms 50.00%  runtime.fastrand1
           0     0%   100%     20ms   100%  main.func·004
           0     0%   100%     20ms   100%  main.pruneAlerts
           0     0%   100%     20ms   100%  runtime.memclr
  </code></pre>
  
  <p>I can't tell where the difference is coming from.</p>