|
Measures the passed time between the construction or calling reset()
and stop()
.
More...
#include <ArmarXCore/core/time/StopWatch.h>
Public Member Functions | |
bool | isStopped () const |
Returns whether the timer is stopped or is actively measuring time. More... | |
void | reset () |
Resets the timer. More... | |
DateTime | startingTime () const |
Returns the date/time at starting the timer. More... | |
Duration | stop () |
Stops the timer and returns the measured duration. More... | |
Duration | stopAndReset () |
Stops and resets the timer. More... | |
DateTime | stoppingTime () const |
Returns the date/time at stopping the timer. More... | |
StopWatch (ClockType clockType=ClockType::Virtual) | |
Constructs a StopWatch and starts it immediately. More... | |
virtual | ~StopWatch () |
Destructs the StopWatch . More... | |
Static Public Member Functions | |
static Duration | measure (std::function< void(void)> subjectToMeasure, ClockType clockType=ClockType::Virtual) |
Measures the duration needed to execute the given lambda and returns it. More... | |
Measures the passed time between the construction or calling reset()
and stop()
.
The StopWatch
uses the system time by default, but it may use the virtual time provided by the time server as well. Also has a static method measure()
, which takes a lambda, and returns the time it took to execute that lambda.
Code examples:
Definition at line 42 of file StopWatch.h.
StopWatch | ( | ClockType | clockType = ClockType::Virtual | ) |
Constructs a StopWatch
and starts it immediately.
clockType | Clock type. |
Definition at line 20 of file StopWatch.cpp.
|
virtual |
Destructs the StopWatch
.
Definition at line 27 of file StopWatch.cpp.
bool isStopped | ( | ) | const |
Returns whether the timer is stopped or is actively measuring time.
Definition at line 59 of file StopWatch.cpp.
|
static |
Measures the duration needed to execute the given lambda and returns it.
subjectToMeasure | Lambda to be measured |
clockType | Clock type. |
Definition at line 34 of file StopWatch.cpp.
void reset | ( | ) |
Resets the timer.
Definition at line 51 of file StopWatch.cpp.
DateTime startingTime | ( | ) | const |
Returns the date/time at starting the timer.
Definition at line 66 of file StopWatch.cpp.
Duration stop | ( | ) |
Stops the timer and returns the measured duration.
Definition at line 43 of file StopWatch.cpp.
Duration stopAndReset | ( | ) |
Stops and resets the timer.
It returns the date/time at stopping the timer.
std::logic_error | When the timer was not stopped yet. |
Definition at line 84 of file StopWatch.cpp.
DateTime stoppingTime | ( | ) | const |
Returns the date/time at stopping the timer.
std::logic_error | When the timer was not stopped yet. |
Definition at line 73 of file StopWatch.cpp.