0

I would like to see the fraction of time spent in a function and all its descendants using perf report. That is, if I have something like

void foo()
{
    biz(); // 3,300 cycles
    baz(); // 3,300 cycles
    // ...      100 cycles
}

int main()
{
    foo();
    bar(); // 3,300 cycles
    return 0;
}

and the functions bar, baz, and biz took 3,300 cycles each, foo itself took only 100 cycles, then I would like to see a graph like:

main 100%
|
+--- foo 67.0% (1.0%)
|    |
|    +--- biz 33.0%
|    +--- baz 33.0%
|
+--- bar 33.0%
JRG
  • 2,065
  • 2
  • 14
  • 29

1 Answers1

0

You have to record data with option -g to collect debug info (from the command help: "Do call-graph (stack chain/backtrace) recording").

Then, to show the callgraph as expected, add the option --stdio, to have a flat but hierarchical output, else you will enter an interactive ncurses mode.

amigadev
  • 396
  • 1
  • 5
  • How does that produce a graph like the above? All `--stdio` does is to dump call stacks. – JRG Oct 28 '14 at 16:57
  • You're right, I'm sorry, I played with reporting options but it seems perf can't show this kind of cumulative descending callgraph. It focus on symbols first for ordering, and then provide the call chain for each symbol. – amigadev Nov 04 '14 at 09:11
  • You should have a look at: http://www.rotateright.com/zoom/ They mention in the Zoom 3.3.2 (last version) release notes that they have removed licencing restrictions (moving into a free software product). – amigadev Nov 04 '14 at 09:25