Simple timer class: add checkpoints throughout the code and measure execution time between them.
When timing parts of code for example inside loops Stopwatch should be used instead.
Usage example:
Timer timer;
timer.addCheckPoint("beg");
timer.addCheckPoint("mid");
timer.addCheckPoint("end");
timer.showTimings("beg", "mid");
std::cout << timer << std::endl;
double t = timer.duration("beg", "end");
- See also
- Stopwatch
Definition at line 29 of file Timer.hpp.
|
void | addCheckPoint (const std::string &label) |
| Adds a checkpoint with given label and remembers the time at which it was added. More...
|
|
void | showTimings (std::ostream &os=std::cout) const |
| Pretty print all durations between checkpoints. More...
|
|
void | showTimings (const std::string &from, const std::string &to, std::ostream &os=std::cout) const |
| Output duration between the checkpoints with given labels to os . More...
|
|
time_type | timeAt (const std::string &label) const |
| Return absolute time for a given label. More...
|
|
double | duration (const std::string &from, const std::string &to) const |
| Return time difference in seconds between two checkpoints. More...
|
|
double | durationToNow (const std::string &from) const |
| Return time difference in seconds between from and now. More...
|
|
int | size () const |
| Return the number of measurements taken. More...
|
|
const std::vector< std::string > & | labels () const |
| Return all labels. More...
|
|
const std::vector< time_type > & | times () const |
| Return all times. More...
|
|
void | clear () |
| Clear all of time points. More...
|
|