I am Ubuntu 16.04 user.
For profiling c++ program I use perf tool. So I run:
perf record ./myprogram myprogram_args
perf report
Now as output I have:
14,52% CSim2Sim libsimgrid.so.3.13.90 [.] lmm_solve
4,40% CSim2Sim libsimgrid.so.3.13.90 [.] lmm_update_modified_set_rec
4,05% CSim2Sim libc-2.23.so [.] _int_malloc
3,30% CSim2Sim libsimgrid.so.3.13.90 [.] simgrid::surf::Model::next_occuring_event_lazy
2,19% CSim2Sim libc-2.23.so [.] _int_free
........................................................................
I see only "depth" and library calls from my program. How can I get report from perf similar to this template? (something like this):
4,52% CSim2Sim my_function1(int argc, char* argv[])
3,52% CSim2Sim my_function2(int argc, char* argv[])
3,52% CSim2Sim my_function3(int argc, char* argv[])
1,52% CSim2Sim my_function4(int argc, char* argv[])
Going from perf over info:perf to Perf Wiki, and finally to Tutorial - Perf Wiki
Source level analysis with perf annotate
...
perf annotate can generate sourcecode level information if the application is compiled with -ggdb. The following snippet shows the much more informative output for the same execution of noploop when compiled with this debugging information.
So compiling (and maybe linking?) with option -ggdb should do the trick.
Then you can use perf record to collect runtime information, and later analyze this with perf annotate.
I just found this answer to Alternatives to gprof [closed]. It recommends using gcc's option -fno-omit-frame-pointer, if you want to get call graph information. So, depending on what you want to achieve and your optimization level, you might need to add this option too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With