Coder Perfect

What is a nice, simple C++ profiler for Linux? [closed]

Problem

I need to profile some code running C++ on Linux. 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 then examine the gmon.out file that your executable generates with gprof.

eg:

gcc -pg -o whatever whatever.c

./whatever

gprof whatever gmon.out

The same goes for 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 favorite 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. The Linux version, I believe, is free for non-commercial software.

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