Problem
On Linux, I need to profile some C++ code. Could you suggest some profilers?
Asked by shergill
Solution #1
Use gprof.
Simply use the -pg flag when compiling (I believe (but am not certain) that optimizations must be disabled.) and use gprof to analyze the gmon.out file that your executable will then produce.
eg:
gcc -pg -o whatever whatever.c
./whatever
gprof whatever gmon.out
Same thing with g++ and cpp.
Answered by smcameron
Solution #2
The linux profiler valgrind is well-known.
Answered by dfa
Solution #3
I’ve been using Zoom from RotateRight (http://www.rotateright.com). It includes a butterfly view of functions and allows you to double-click any function to get straight to the source or asm code. To inspect your source, build with debugging information (-g), but you should still build and profile optimized code.
Answered by XWare
Solution #4
Oprofile is a favourite of mine. It requires the installation of a kernel module and has a learning curve, but it’s fairly powerful and works well for efficient programs/programs that don’t use debugging symbols.
Intel’s Vtune is yet another sophisticated profiler. For non-commercial software, I believe the Linux version is free.
There’s also the dfa-recommended Valgrind set of tools. It’s likely that Callgrind is what you’re most interested in. Cachegrind (whose featureset is a subset of Callgrind’s) and Massif are both intriguing, although I’ve never used either.
Answered by Falaina
Solution #5
Look into KCacheGrind, a graphical frontend to valgrind that makes it very simple to use.
Answered by Milan Babuškov
Post is based on https://stackoverflow.com/questions/1168766/what-is-a-good-easy-to-use-profiler-for-c-on-linux