Replace it with
#include <boost/progress.hpp> void function() { progress_timer t; // start timing // do stuff return 0; }
and you get what you want but donโt use printf .
The timer starts with construction and is displayed upon destruction (i.e., at the output of fn). This is usually an RAII way to perform tasks with scope (synchronization, locking, etc.) in C ++.
Steve townsend
source share