OProfile is a system-wide profiler for Linux systems, capable of profiling all running code at low overhead. OProfile is released under the GNU GPL.
Configuring and Installing OProfile:
I was surprised to know that OProfiler is not available in Ubuntu 12.04 repository. But building OProfiler from source code is not a difficult task. You can download OProfiler source code from this link.
OProfiler depends on libraries like popt, libiberty, QT3, etc. We have to make sure that we have these libraries installed before configuring and installing OProfiler.
sudo apt-get install libpopt-dev binutils-dev
Now its time to kick start configure and install OProfile,
./configure make sudo make install
If you don’t want to mess up your current /usr/bin/ directory, you can install OProfiler to directory of your choice. In this case I have installed it to /home/teja/install/.
./configure --prefix=/home/teja/install/ make make install
Make sure that you have the updated your .bashrc to use the installed binaries,
Note: I have built OProfiler without GUI support. You have to install QT3 libraries if you want to graphically visualize profiler output.
One nice thing about OProfile is it doesn’t need instrumentation or recompilation of code. You can directly run operf command un your executable,
operf <<executable_name>> opreport <<executable_name>>
To display the output using callgraph,
operf --callgraph <<executable_name>> opreport --callgraph <<executable_name>>