|
| CpuTimer (std::ostream &os=std::cerr) |
| Initiate timer. More...
|
|
| CpuTimer (const std::string &msg, std::ostream &os=std::cerr) |
| Prints message and start timer. More...
|
|
void | start () |
| Start timer. More...
|
|
void | start (const std::string &msg) |
| Print message and start timer. More...
|
|
int64_t | microseconds () const |
| Return Time difference in microseconds since construction or start was called. More...
|
|
double | milliseconds () const |
| Return Time difference in milliseconds since construction or start was called. More...
|
|
double | seconds () const |
| Return Time difference in seconds since construction or start was called. More...
|
|
std::string | time () const |
|
double | stop () const |
| Returns and prints time in milliseconds since construction or start was called. More...
|
|
double | stop (const std::string &msg) const |
| Returns and prints time in milliseconds since construction or start was called. More...
|
|
double | restart () |
| Re-start timer. More...
|
|
double | restart (const std::string &msg) |
| Stop previous timer, print message and re-start timer. More...
|
|
Simple timer for basic profiling.
util::CpuTimer timer;
timer.start("algorithm");
timer.stop();
or to time multiple blocks of code
util::CpuTimer timer("algorithm 1");
timer.restart("algorithm 2");
timer.stop();
or to measure speedup between multiple runs
util::CpuTimer timer("algorithm 1");
const double t1 = timer.restart("algorithm 2");
const double t2 = timer.stop();
std::cerr << "Algorithm 1 is " << (t2/t1)
<< " timers faster than algorithm 2\n";
or to measure multiple blocks of code with deferred output
util::CpuTimer timer();
timer.start();
const double t1 = timer.restart();
const double t2 = timer.restart();