7 : accumulatedTime(
std::chrono::nanoseconds::
zero()), isStopped(true), startOfCurrentMeasurement(
std::chrono::nanoseconds::
zero()) {
14 auto time = accumulatedTime;
16 time += std::chrono::high_resolution_clock::now() - startOfCurrentMeasurement;
18 return std::chrono::duration_cast<std::chrono::seconds>(time).count();
22 auto time = accumulatedTime;
24 time += std::chrono::high_resolution_clock::now() - startOfCurrentMeasurement;
26 return std::chrono::duration_cast<std::chrono::milliseconds>(time).count();
30 return accumulatedTime.count();
34 accumulatedTime += timeNanoseconds;
39 accumulatedTime += other.accumulatedTime;
45 accumulatedTime += std::chrono::high_resolution_clock::now() - startOfCurrentMeasurement;
51 startOfCurrentMeasurement = std::chrono::high_resolution_clock::now();
55 accumulatedTime = std::chrono::nanoseconds::zero();
69 char oldFillChar = out.fill(
'0');
71 out.fill(oldFillChar);
A class that provides convenience operations to display run times.
bool stopped() const
Retrieves whether the watch is stopped.
void addToTime(std::chrono::nanoseconds timeNanoseconds)
Add given time to measured time.
decltype(std::chrono::duration_cast< std::chrono::milliseconds >(std::chrono::milliseconds::zero()).count()) MilisecondType
Stopwatch(bool startNow=false)
Constructor.
MilisecondType getTimeInMilliseconds() const
Gets the measured time in milliseconds.
void start()
Start stopwatch (again) and start measuring time.
NanosecondType getTimeInNanoseconds() const
Gets the measured time in nanoseconds.
decltype(std::chrono::duration_cast< std::chrono::seconds >(std::chrono::seconds::zero()).count()) SecondType
void restart()
Reset the stopwatch and immediately start it.
SecondType getTimeInSeconds() const
Gets the measured time in seconds.
void reset()
Reset the stopwatch.
void stop()
Stop stopwatch and add measured time to total time.
decltype(std::chrono::duration_cast< std::chrono::nanoseconds >(std::chrono::nanoseconds::zero()).count()) NanosecondType
void add(Stopwatch const &other)
Adds the value of the (stopped) watch to the accumulated time of this watch.
#define STORM_LOG_WARN_COND(cond, message)
std::ostream & operator<<(std::ostream &os, Engine const &engine)
Writes the string representation of the given engine to the given stream.