Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
Stopwatch.h
Go to the documentation of this file.
1#ifndef STORM_UTILITY_STOPWATCH_H_
2#define STORM_UTILITY_STOPWATCH_H_
3
4#include <chrono>
5
7
8namespace storm {
9namespace utility {
10
14class Stopwatch {
15 public:
16 typedef decltype(std::chrono::duration_cast<std::chrono::seconds>(std::chrono::seconds::zero()).count()) SecondType;
17 typedef decltype(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::milliseconds::zero()).count()) MilisecondType;
18 typedef decltype(std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::nanoseconds::zero()).count()) NanosecondType;
19
25 Stopwatch(bool startNow = false);
26
31
36
41
47 void addToTime(std::chrono::nanoseconds timeNanoseconds);
48
52 void add(Stopwatch const& other);
53
57 void stop();
58
62 void start();
63
67 void reset();
68
72 void restart();
73
77 bool stopped() const;
78
79 friend std::ostream& operator<<(std::ostream& out, Stopwatch const& stopwatch);
80
81 private:
82 // The time accumulated so far.
83 std::chrono::nanoseconds accumulatedTime;
84
85 // A flag indicating if the stopwatch is stopped right now.
86 bool isStopped;
87
88 // The timepoint when the stopwatch was started the last time (if it's not stopped).
89 std::chrono::high_resolution_clock::time_point startOfCurrentMeasurement;
90};
91
92std::ostream& operator<<(std::ostream& out, Stopwatch const& stopwatch);
93} // namespace utility
94} // namespace storm
95
96#endif /* STORM_UTILITY_STOPWATCH_H_ */
A class that provides convenience operations to display run times.
Definition Stopwatch.h:14
bool stopped() const
Retrieves whether the watch is stopped.
Definition Stopwatch.cpp:64
void addToTime(std::chrono::nanoseconds timeNanoseconds)
Add given time to measured time.
Definition Stopwatch.cpp:33
decltype(std::chrono::duration_cast< std::chrono::milliseconds >(std::chrono::milliseconds::zero()).count()) MilisecondType
Definition Stopwatch.h:17
MilisecondType getTimeInMilliseconds() const
Gets the measured time in milliseconds.
Definition Stopwatch.cpp:21
friend std::ostream & operator<<(std::ostream &out, Stopwatch const &stopwatch)
Definition Stopwatch.cpp:68
void start()
Start stopwatch (again) and start measuring time.
Definition Stopwatch.cpp:48
NanosecondType getTimeInNanoseconds() const
Gets the measured time in nanoseconds.
Definition Stopwatch.cpp:29
decltype(std::chrono::duration_cast< std::chrono::seconds >(std::chrono::seconds::zero()).count()) SecondType
Definition Stopwatch.h:16
void restart()
Reset the stopwatch and immediately start it.
Definition Stopwatch.cpp:59
SecondType getTimeInSeconds() const
Gets the measured time in seconds.
Definition Stopwatch.cpp:13
void reset()
Reset the stopwatch.
Definition Stopwatch.cpp:54
void stop()
Stop stopwatch and add measured time to total time.
Definition Stopwatch.cpp:42
decltype(std::chrono::duration_cast< std::chrono::nanoseconds >(std::chrono::nanoseconds::zero()).count()) NanosecondType
Definition Stopwatch.h:18
void add(Stopwatch const &other)
Adds the value of the (stopped) watch to the accumulated time of this watch.
Definition Stopwatch.cpp:37
std::ostream & operator<<(std::ostream &os, Engine const &engine)
Writes the string representation of the given engine to the given stream.
Definition Engine.cpp:65
LabParser.cpp.
Definition cli.cpp:18