Go to the documentation of this file.
5 #include <IceUtil/Time.h>
15 const IceUtil::Time timestamp_invalid = IceUtil::Time::milliSeconds(-1);
45 _time = _clock.
now() - _startingTime;
53 _startingTime = _clock.
now();
77 throw std::logic_error{
"Timer was not stopped yet, cannot assess stopping time."};
80 return _startingTime + _time;
86 const auto duration =
stop();
100 m_time_mode{timeMode},
102 m_time{::timestamp_invalid}
135 m_time = ::timestamp_invalid;
142 return m_time != ::timestamp_invalid;
149 return m_starting_time;
158 throw std::logic_error{
"Timer was not stopped yet, cannot assess stopping time."};
161 return m_starting_time + m_time;
bool isStopped() const
Returns whether the timer is stopped or is actively measuring time.
DateTime startingTime() const
Returns the date/time at starting the timer.
StopWatch(armarx::TimeMode timeMode=armarx::TimeMode::SystemTime)
static IceUtil::Time measure(std::function< void(void)> subjectToMeasure, armarx::TimeMode timeMode=armarx::TimeMode::SystemTime)
bool isPositive() const
Tests whether the duration is positive (value in µs > 0).
Duration stop()
Stops the timer and returns the measured duration.
IceUtil::Time startingTime() const
static Duration Seconds(std::int64_t seconds)
Constructs a duration in seconds.
ClockType
Describes the type of clock.
Duration stopAndReset()
Stops and resets the timer.
armarx::core::time::DateTime Time
static IceUtil::Time GetTime(TimeMode timeMode=TimeMode::VirtualTime)
Get the current time.
Represents a point in time.
TimeMode
Time mode to be used.
static IceUtil::Time GetTimeSince(IceUtil::Time referenceTime, TimeMode timeMode=TimeMode::VirtualTime)
Get the difference between the current time and a reference time.
static Duration measure(std::function< void(void)> subjectToMeasure, ClockType clockType=ClockType::Virtual)
Measures the duration needed to execute the given lambda and returns it.
Measures the passed time between the construction or calling reset() and stop().
virtual ~StopWatch()
Destructs the StopWatch.
StopWatch(ClockType clockType=ClockType::Virtual)
Constructs a StopWatch and starts it immediately.
IceUtil::Time stoppingTime() const
DateTime stoppingTime() const
Returns the date/time at stopping the timer.
This file offers overloads of toIce() and fromIce() functions for STL container types.
void reset()
Resets the timer.
DateTime now() const
Current date/time of the clock.