On Linux, I need to profile some C++ code. Could you suggest some profilers?
Asked by shergill
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.
gcc -pg -o whatever whatever.c ./whatever gprof whatever gmon.out
Same thing with g++ and cpp.
Answered by smcameron
The linux profiler valgrind is well-known.
Answered by dfa
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
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
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