You could also try some timer classes that start and stop automatically, and gather statistics on the average, maximum and minimum time spent in any block of code, as well as the number of calls. These cxx-rtimer classes are available on GitHub, and offer support for using std::chrono, clock_gettime(), or boost::posix_time as a back-end clock source.
With these timers, you can do something like:
void timeCriticalFunction() { static rtimers::cxx11::DefaultTimer timer("expensive"); auto scopedStartStop = timer.scopedStart(); // Do something costly...}
with timing stats written to std::cerr on program completion.