Jump to: navigation, search

Linux systems count with a wide variety of profilers each of with their pros and cons, there is no magic bullet, it's recommended to use more than one tool when analyzing your application, I recommend you to use at least OProfile and Valgrind.


OProfile is a non-obtrusive system-wide profiler for Linux, it can use system's performance counters to give you insights on where to optimize your code.

Helper script for simple runs (remember to run opcontrol --setup ... once before this script):

sudo opcontrol --init
sudo opcontrol --start
sudo opcontrol --dump
sudo opcontrol --reset
sudo opcontrol --stop
opreport --symbols > oprof.txt

see also oprof_start

User Interfaces


Qt3 GUI for OProfile, ships in official distribution, see


One can use reports that are usable by kcachegrind with (for more instruction see

opreport -gdf | op2callgrind 


Another useful application is OProfileUI, it provides a GTK+2 user interface to run and show statistics, including basic call graph.


In depth explanation can be found at:


  • JFFS2 does not provide OProfile requirements, running OProfile to output data into JFFS2 partition will fail, instead use a ramfs or some external card with ext2/3:
mkdir /var/lib/oprofile
# ram
mount -t ramfs none /var/lib/oprofile
# ext3
mount -t ext3 /dev/sda1 /var/lib/oprofile
  • settings event counter too low or too high may hang your test machine. Check the recommended value for each event on specific platforms.


Unlike OProfile, GProf requires applications to be compiled with special flag -pg so compiler will introduce marks in generated binary to measure runs. After run the gmon.out file will be created with measured data, this file can be viewed with tools like gprof or kprof.

User Interfaces


Outdated, but exists:



  • Imprecise
  • Huge overhead

ARM Streamline

ARM Streamline is a commercial sample-based system performance analyzer which brings together performance counters from the core(s) and OS, time- and event-based profiling, context switch tracepoints, and instrumented messages (like printf) to provide developers with a system-to-instruction drill-down ability.

Streamline is a component of the ARM DS-5 suite, which has a 30-day evaluation version available for download.

Valgrind Cachegrind/Callgrind

Valgrind is tool suite for debugging and profiling. It's most famous for it's memcheck tool to check for memory leaks, invalid access, double frees and more, but also ships with interesting callgrind and cachegrind.

cachegrind will accurately simulate L1, L2 and D1 CPU caches so you can figure out what in your code is trashing your memory access.

callgrind is an extension of cachegrind that will collect call graphs.

User Interfaces


The most famous user interface is KCachegrind



  • Since these are simulators, your application will run very slow, from 20 to 100 times or more.