#include <timer.h>
Public Types | |
typedef struct timeval | value_t |
Public Member Functions | |
Timer (bool startnow=true) | |
~Timer () | |
void | start () |
void | stop () |
void | reset (void) |
double | operator() (void) const |
double | time_since_start (void) const |
Simple timer class.
This class allows you to time things, for runtime statistics and the like. The simplest usage pattern is illustrated by the following example:
Timer mytimer; // automatically starts upon construction ...do stuff float t = mytimer(); // seconds elapsed since start Timer another (false); // false means don't start ticking yet another.start (); // start ticking now another.stop (); // stop ticking another.start (); // start again where we left off another.stop (); another.reset (); // reset to zero time again
Timer::Timer | ( | bool | startnow = true |
) | [inline] |
Constructor -- reset at zero, and start timing unless optional 'startnow' argument is false.
Timer::~Timer | ( | ) | [inline] |
Destructor.
double Timer::operator() | ( | void | ) | const [inline] |
Operator () returns the elapsed time so far, including both the currently-ticking clock as well as any previously elapsed time.
void Timer::reset | ( | void | ) | [inline] |
Reset at zero and stop ticking.
void Timer::start | ( | ) | [inline] |
Start ticking, or restart if we have stopped.
void Timer::stop | ( | ) | [inline] |
Stop ticking. Any elapsed time will be saved even though we aren't currently ticking.
double Timer::time_since_start | ( | void | ) | const [inline] |
Return just the time since we called start(), not any elapsed time in previous start-stop segments.