On 05/25/2015 05:14 PM, Andi Kleen wrote: >>> perf diff does not handle this? Especially with the differential >>> profiling options it should. >> >> It does not work if you, in my case, compare ICC and GCC, where ICC uses a different mangling >> scheme for fortran modules. Moreover, situation can be more complicated if a compiler performs >> a bit different inlining decisions. > > I suppose it could be enhanced with an input file that describes > equivalent functions. But yes wouldn't work for inlining. > >> Good point. Can you please help me how to compute a function percentage usage in perf annotate ;) ? > > I wouldn't use time at all. Just sum up periods and then compute the > percentage. The period sum computation already happens in the main view, and > is displayed there. So you only need to save that value somewhere and > then use it in the annotate display for another column. > > # Samples: 24 of event 'cycles' > # Event count (approx.): 8856637 > > -Andi > Hello. Are you talking about summing cycles and compute global percentage for each isntruction? Anyway, attached patch is capable of displaying milliseconds approximation for each instruction. Example: time ./perf record ./a.out [ perf record: Woken up 7 times to write data ] [ perf record: Captured and wrote 1.743 MB perf.data (45386 samples) ] real 0m11.465s user 0m11.424s sys 0m0.045s $ perf report --stdio 32.69% a.out libc-2.19.so [.] __random_r 26.66% a.out libc-2.19.so [.] __random 12.55% a.out a.out [.] foo 10.14% a.out a.out [.] bar 9.27% a.out a.out [.] baz 7.22% a.out libc-2.19.so [.] rand 1.37% a.out a.out [.] rand@plt $ perf annotate --stdio Percent | Source code & Disassembly of libc-2.19.so for cycles -------------------------------------------------------------------- : : : : Disassembly of section .text: : : 0000000000038890 : : __random_r(): 11.12 : 38890: test %rdi,%rdi $ perf annotate --stdio --show-total-period Percent | Source code & Disassembly of libc-2.19.so for cycles -------------------------------------------------------------------- : : : : Disassembly of section .text: : : 0000000000038890 : : __random_r(): 413 : 38890: test %rdi,%rdi First `test` instruction: 11465*0.3269*0.1112 ~ 413ms. Thanks for suggestions, Martin