Cprof is an enhanced performance profiler tool written in C++ for use with C/C++ programs under GNU/Linux. It was developed by Andrew Lewycky while a co-op at Corel Corporation. It was used mostly for performance profiling of Wine but is applicable to other programs.
What Can it Do?Both flat profiles and call graphs a'la gprof are supported. Profiling multithreaded programs works out of the box.
What Can't it Do?Profile shared libraries (although there is a profiler in the gnome CVS from Eazel which is a modified cprof that does.) Demangle C++ symbol names (run output through c++-filt for this.)
To Build and Use Tarballs
To Hack cprof
The 1.0.2 release has been tried (both from CVS and the tarball) on Debian 3.0, Red Hat 7.3 and Red Hat 9.0 systems. Please report any problems so that a fix can be found.
The 1.0.1 release is just the last public release of cprof from Corel uploaded to sourceforge. It doesn't build nicely with more modern automake/autoconf versions, and does not include the configure script (ie. you must have automake/autoconf/libtoolize to build it.)
See cprof.html for a mini-HOWTO on building, installing, and using cprof.
To profile a program, compile each object for profiling:
gcc -finstrument-functions -c slow_code.c
Then link against libcprof:
gcc slow_code.o -o slow_code -lcprof
Run the program once, to generate cmon.out in the current directory. Run cprofcompr without any arguments to compress cmon.out. Run cprof as
cprof slow_code > slow_code.prof
to get a text summary of the profiling results.
cprof --help has more information on the command line syntax and useful arguments.