shameless self-promoting website
»Rejourn root
Posted Sunday, 11 January 2009 by Miklos
Tags: en hacking

I did not have to work with a profiling tool for C so far, so here is my first experience.

The kernel has to have oprofile support (the kernel in Frugalware-current does not have it, I'll add it after 1.0pre2). You'll need a kernel vmlinux file if you want to benchmark the syscalls as well (I did not need this one).

Then there are 3 levels of starting: opcontrol --init/--deinit, --start-daemon/--shutdown and --start/--stop. The first one prepares /dev/profile, the second one starts the deamon, finally the third one start profiling. Obviously the second part does the opposite.

Once you did a --stop, you can get the results. Example output:

$ opreport -l /home/vmiklos/git/git/git /usr/lib/libz.so.1|head
CPU: CPU with timer interrupt, speed 0 MHz (estimated)
Profiling through timer interrupt
samples  %        app name                 symbol name
22823    56.4898  libz.so.1.2.3            inflate_fast
6019     14.8978  libz.so.1.2.3            adler32
5975     14.7889  libz.so.1.2.3            inflate
4233     10.4772  libz.so.1.2.3            inflate_table
456       1.1287  libz.so.1.2.3            crc32
252       0.6237  git                      patch_delta
55        0.1361  git                      use_pack

which is pretty much what I expected - I did a 'git verify-pack' between --start/--stop, so the time spent with reading the compressed git object database.

TBH I miss a strace/sudo-like simple wrapper as well...