A timer object to measure elapsed time. More...
#include <Timer.hpp>
Public Member Functions | |
TimeDuration | elapsed () const |
UINT32 | elapsedMicroseconds () const |
Returns the elapsed time in microseconds since the timer was started or restarted. | |
UINT32 | elapsedMicrosecondsSinceLastCall () |
Elapsed us since the last call of this function. | |
UINT32 | elapsedMilliseconds () const |
Returns the elapsed time in milliseconds since the timer was started or restarted. | |
UINT32 | elapsedMillisecondsSinceLastCall () |
Elapsed ms since the last call of this function. | |
bool | isElapsed () |
void | reset () |
void | restart () |
Restarts the timer. | |
void | startWatchdog (TimeDuration watchdogTime) |
Timer () | |
Constructor. | |
virtual | ~Timer () |
Destructor. | |
Private Attributes | |
Time | m_startTime |
TimeDuration | m_watchdogTime |
A timer object to measure elapsed time.
This class is intended for simple timing diagnostics during debug phase. For a more accurate profiling of your code use a profiler like valgrind or similar.
Due to accuracy differences on various platforms for Windows PCs and Linux PCs implementations and accuracy may differ.
Timer::Timer | ( | ) |
Timer::~Timer | ( | ) | [virtual] |
TimeDuration Timer::elapsed | ( | ) | const |
UINT32 Timer::elapsedMicroseconds | ( | ) | const |
UINT32 Timer::elapsedMilliseconds | ( | ) | const |
Elapsed ms since the last call of this function.
Elapsed time since last call to this function, in [ms]. This function may be called without restarts as it measures the time between consecutive calls to this function. Usage:
t; // ... t.elapsedMillisecondsSinceLastCall(); // ... functions to be timed ... UINT32 time1 = t.elapsedMillisecondsSinceLastCall(); // ... next functions to be timed ... UINT32 time2 = t.elapsedMillisecondsSinceLastCall(); // ...
Thats it!
bool Timer::isElapsed | ( | ) |
void Timer::reset | ( | ) |
void Timer::restart | ( | ) |
void Timer::startWatchdog | ( | TimeDuration | watchdogTime | ) |
Time Timer::m_startTime [private] |
TimeDuration Timer::m_watchdogTime [private] |