Scopira
20080306
|
#include <time.h>
Public Member Functions | |
chrono (void) | |
void | reset (void) |
void | start (void) |
void | stop (void) |
double | get_total_time (void) const |
double | get_lap_time (void) const |
double | get_running_time (void) const |
A handy class that like a stop watch, can be used to measure the passing of time.
The chrono has two states:
And two counters:
Sample usage:
scopira::tool::chrono::chrono | ( | void | ) |
Constructor. The initial state of the chrono is stopped, so you must explicitly start() it.
The chrono has two counters, both of which are zeroed:
double scopira::tool::chrono::get_lap_time | ( | void | ) | const |
double scopira::tool::chrono::get_running_time | ( | void | ) | const |
Gets the current time, in seconds, since the last start().
This is called when the chrono is running, and can be used to poll the chrono.
double scopira::tool::chrono::get_total_time | ( | void | ) | const |
void scopira::tool::chrono::reset | ( | void | ) |
Resets the stop watch counters to zero.
void scopira::tool::chrono::start | ( | void | ) |
Starts the chrono.
void scopira::tool::chrono::stop | ( | void | ) |
Stops the stop watch (you must have start() it) previously.
get_lap_time() may be used to retreave the time since the start(). This time will be added to the total time, which can be retreived with get_total_time()