|Version 1 (modified by simonmar, 7 years ago) (diff)|
OProfile does a system-wide profile using performance counters. It can also generate annotated source/assembly just like VTune.
It can be installed from a package on Ubuntu, which is cool. But beware: Ubuntu bug 172495: https://bugs.launchpad.net/ubuntu/+source/oprofile/+bug/172495/ : change the /bin/sh to /bin/bash at the top of /usr/bin/opcontrol.
There seems to be a problem with the counters just stopping arbitrarily, requiring a restart of the daemon.
Recipe for profiling something:
$ sudo opcontrol --init $ sudo opcontrol --reset $ sudo opcontrol --start $ ... run program... $ sudo opcontrol --stop $ sudo opreport
check that the program you ran is at the top of the profile somewhere. Sometimes for me it doesn't appear, and have to run it again.
Then to annotate the source:
$ sudo opannotate --source <program> >&! log}}} lists the contents of source files in order of importance. Alternatively use --output-dir to put the source files in a directory, but then you don't get to find out which are the important ones.