Linux C++ Profiler

callgrind + kcachegrind are two nice tools for profiling C++ code.

Assuming your program is called main, use as

valgrind --tool=callgrind --callgrind-out-file=callgrind.out ./main && kcachegrind callgrind.out