Measures the passed time between the construction or calling reset() and stop().
More...
#include <ArmarXCore/core/time/StopWatch.h>
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:
long_operation();
std::cout << "Operation took " << duration << ".";
Represents a duration.
Definition Duration.h:17
Duration stop()
Stops the timer and returns the measured duration.
Definition StopWatch.cpp:39
StopWatch(ClockType clockType=ClockType::Virtual)
Constructs a StopWatch and starts it immediately.
Definition StopWatch.cpp:19
long_operation();
});
std::cout << "Operation took " << duration << ".";
static Duration measure(std::function< void(void)> subjectToMeasure, ClockType clockType=ClockType::Virtual)
Measures the duration needed to execute the given lambda and returns it.
Definition StopWatch.cpp:31
◆ StopWatch()
Constructs a StopWatch and starts it immediately.
- Parameters
-
◆ ~StopWatch()
◆ isStopped()
Returns whether the timer is stopped or is actively measuring time.
- Returns
- True of timer is stopped, false otherwise.
◆ measure()
Measures the duration needed to execute the given lambda and returns it.
- Parameters
-
| subjectToMeasure | Lambda to be measured |
| clockType | Clock type. |
- Returns
- Time it took to execute the given lambda.
◆ reset()
◆ startingTime()
Returns the date/time at starting the timer.
- Returns
- Date/time at starting the timer.
◆ stop()
Stops the timer and returns the measured duration.
- Returns
- Duration elapsed since construction or last call of
reset().
◆ stopAndReset()
Stops and resets the timer.
It returns the date/time at stopping the timer.
- Returns
- Date/time at stopping the timer.
- Exceptions
-
| std::logic_error | When the timer was not stopped yet. |
◆ stoppingTime()
Returns the date/time at stopping the timer.
- Returns
- Date/time at stopping the timer.
- Exceptions
-
| std::logic_error | When the timer was not stopped yet. |
The documentation for this class was generated from the following files: