#include <CoinTime.hpp>
Public Member Functions | |
CoinTimer () | |
Default constructor creates a timer with no time limit and no tracing. | |
CoinTimer (double lim) | |
Create a timer with the given time limit and with no tracing. | |
void | restart () |
Restart the timer (keeping the same time limit). | |
void | reset () |
An alternate name for restart() . | |
void | reset (double lim) |
Reset (and restart) the timer and change its time limit. | |
bool | isPastPercent (double pct) const |
bool | isPast (double lim) const |
bool | isExpired () const |
double | timeLeft () const |
Private Member Functions | |
bool | evaluate (const bool b_tmp) const |
double | evaluate (const double d_tmp) const |
Private Attributes | |
double | start |
When the timer was initialized/reset/restarted. | |
double | limit |
double | end |
The timer stores the start time of the timer, for how much time it was set to and when does it expire (start + limit = end). Queries can be made that tell whether the timer is expired, is past an absolute time, is past a percentage of the length of the timer. All times are given in seconds, but as double numbers, so there can be fractional values.
The timer can also be initialized with a stream and a specification whether to write to or read from the stream. In the former case the result of every query is written into the stream, in the latter case timing is not tested at all, rather the supposed result is read out from the stream. This makes it possible to exactly retrace time sensitive program execution.
Definition at line 60 of file CoinTime.hpp.
|
Return whether the originally specified time limit has passed since the timer was started Definition at line 153 of file CoinTime.hpp.
00153 {
00154 return evaluate(end < CoinCpuTime());
00155 }
|
|
Return whether the given amount of time has elapsed since the timer was started Definition at line 148 of file CoinTime.hpp. References start.
00148 {
00149 return evaluate(start + lim > CoinCpuTime());
00150 }
|
|
Return whether the given percentage of the time limit has elapsed since the timer was started Definition at line 143 of file CoinTime.hpp. References start.
00143 {
00144 return evaluate(start + limit * pct > CoinCpuTime());
00145 }
|
|
Return how much time is left on the timer Definition at line 158 of file CoinTime.hpp.
00158 {
00159 return evaluate(end - CoinCpuTime());
00160 }
|