|
3es
0.7
|
A high precision timer implementation. More...
#include <3estimer.h>
Public Member Functions | |
| Timer () | |
| Constructor. Verifies data size. | |
| void | start () |
| Starts the timer by recording the current time. | |
| long long | restart () |
| Restarts the timer and returns the time elapsed until this call. More... | |
| void | mark () |
| Records the current time as the end time for elapsed calls. | |
| bool | hasElapsedMs (long long milliseconds) |
| Checks to see if the given time interval has elapsed. More... | |
| long long | elapsedNowMS () |
| Return the time elapsed now. More... | |
| long long | elapsedNowUS () |
| Return the time elapsed now. More... | |
| void | elapsed (unsigned int &seconds, unsigned int &milliseconds, unsigned int µseconds) const |
Calculates the elapsed time between start() and mark(). More... | |
| void | elapsed (Timing &timing) const |
Calculates the elapsed time between start() and mark(). More... | |
| void | elapsedNow (Timing &timing) |
Marks the current end time (mark()) and calculates the elapsed time since start(). More... | |
| double | elapsedS () const |
| Determines the elapsed time between recorded start and mark times. More... | |
| long long | elapsedMS () const |
| Determines the elapsed time between recorded start and mark times. More... | |
| long long | elapsedUS () const |
| Determines the elapsed time between recorded start and mark times. More... | |
Static Public Member Functions | |
| static void | split (long long timeNs, Timing &timing) |
| Splits a nanoseconds value. More... | |
| static void | split (long long timeUs, unsigned int &seconds, unsigned int &milliseconds, unsigned int µseconds) |
| Splits a microsecond value into seconds and milliseconds. More... | |
A high precision timer implementation.
Actual precision is platform dependent.
On Windows, uses QueryPerformanceCounter(). Unix based platforms use gettimeofday().
General usage is to call start() at the start of timing and mark() at the end. Various elapsed methods may be used to determine the elapsed time.
A timer may be restarted by calling start() and mark() again. A timer cannot be paused.
| void tes::Timer::elapsed | ( | unsigned int & | seconds, |
| unsigned int & | milliseconds, | ||
| unsigned int & | microseconds | ||
| ) | const |
Calculates the elapsed time between start() and mark().
The result is broken up into seconds, ms and us.
| [out] | seconds | The number of whole seconds elapsed. |
| [out] | milliseconds | The number of whole milliseconds elapsed [0, 999]. |
| [out] | microseconds | The number of whole microseconds elapsed [0, 999]. |
| void tes::Timer::elapsed | ( | Timing & | timing | ) | const |
| long long tes::Timer::elapsedMS | ( | ) | const |
| void tes::Timer::elapsedNow | ( | Timing & | timing | ) |
| long long tes::Timer::elapsedNowMS | ( | ) |
Return the time elapsed now.
Similar to calling mark() then elapsedMS(). This destroys information recorded on the last mark() call.
| long long tes::Timer::elapsedNowUS | ( | ) |
Return the time elapsed now.
Similar to calling mark() then elapsedUS(). This destroys information recorded on the last mark() call.
| double tes::Timer::elapsedS | ( | ) | const |
| long long tes::Timer::elapsedUS | ( | ) | const |
| bool tes::Timer::hasElapsedMs | ( | long long | milliseconds | ) |
| long long tes::Timer::restart | ( | ) |
|
static |
Splits a nanoseconds value.
| timeNs | The nanoseconds only value to split. | |
| [out] | timing | Elapsed timing written here. |
|
static |
Splits a microsecond value into seconds and milliseconds.
| timeUs | The microseconds only value to split. |
| seconds | The number of whole seconds in timeUs |
| milliseconds | The number of whole milliseconds in timeUs. |
| microseconds | The remaining microseconds left in timeUs. Always < 1000. |