STXXL  1.4-dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Timestamp and Timer Classes

See also file common/timer.h

Measuring the time certain parts of an algorithm or the entire algorithm consume will often be of great interest. The STXXL provides build-in time measurement class stxxl::timer which can be used as follows:

#include <stxxl/timer> // make timer class available
stxxl::timer Timer; // create Timer object
Timer.start();
// code section which shall be measured
Timer.stop();
// get results:
STXXL_MSG(",easured time: " << (Timer.seconds()) << " (seconds), " << (Timer.mseconds()) << " (milliseconds), " << (Timer.useconds()) << " (microseconds))
Timer.reset(); // reset clock to zero which allows to run start() again

As an alternative, one can also work on the timestamp itself:

double start = stxxl::timestamp();
// code section to be measured
double stop = stxxl::timestamp();
STXXL_MSG("measured time: " << (stop - start) << " seconds.");