The Stopwatch keeps track of time spent in the run state, accessed through ElapsedRunTime(), and time spent in the stop state, accessed through ElapsedStopTime(). Elapsed run time starts accumulating after the first call to Start(). Elapsed stop time starts accumulation after Start() has been called followed by Stop(). The stopwatch can be reset with the Reset() function. More...
#include <gz/math/Stopwatch.hh>
Public Member Functions | |
Stopwatch () | |
Constructor. More... | |
clock::duration | ElapsedRunTime () const |
Get the amount of time that the stop watch has been running. This is the total amount of run time, spannning all start and stop calls. The Reset function or passing true to the Start function will reset this value. More... | |
clock::duration | ElapsedStopTime () const |
Get the amount of time that the stop watch has been stopped. This is the total amount of stop time, spannning all start and stop calls. The Reset function or passing true to the Start function will reset this value. More... | |
bool | operator!= (const Stopwatch &_watch) const |
Inequality operator. More... | |
bool | operator== (const Stopwatch &_watch) const |
Equality operator. More... | |
void | Reset () |
Reset the stopwatch. This resets the start time, stop time, elapsed duration and elapsed stop duration. More... | |
bool | Running () const |
Get whether the stopwatch is running. More... | |
bool | Start (const bool _reset=false) |
Start the stopwatch. More... | |
clock::time_point | StartTime () const |
Get the time when the stopwatch was started. More... | |
bool | Stop () |
Stop the stopwatch. More... | |
clock::time_point | StopTime () const |
Get the time when the stopwatch was last stopped. More... | |
Detailed Description
The Stopwatch keeps track of time spent in the run state, accessed through ElapsedRunTime(), and time spent in the stop state, accessed through ElapsedStopTime(). Elapsed run time starts accumulating after the first call to Start(). Elapsed stop time starts accumulation after Start() has been called followed by Stop(). The stopwatch can be reset with the Reset() function.
Example usage
Constructor & Destructor Documentation
◆ Stopwatch()
Stopwatch | ( | ) |
Constructor.
Member Function Documentation
◆ ElapsedRunTime()
clock::duration ElapsedRunTime | ( | ) | const |
Get the amount of time that the stop watch has been running. This is the total amount of run time, spannning all start and stop calls. The Reset function or passing true to the Start function will reset this value.
- Returns
- Total amount of elapsed run time.
◆ ElapsedStopTime()
clock::duration ElapsedStopTime | ( | ) | const |
Get the amount of time that the stop watch has been stopped. This is the total amount of stop time, spannning all start and stop calls. The Reset function or passing true to the Start function will reset this value.
- Returns
- Total amount of elapsed stop time.
◆ operator!=()
bool operator!= | ( | const Stopwatch & | _watch | ) | const |
Inequality operator.
- Parameters
-
[in] _watch The watch to compare.
- Returns
- True if this watch does not equal the provided watch.
◆ operator==()
bool operator== | ( | const Stopwatch & | _watch | ) | const |
Equality operator.
- Parameters
-
[in] _watch The watch to compare.
- Returns
- True if this watch equals the provided watch.
◆ Reset()
void Reset | ( | ) |
Reset the stopwatch. This resets the start time, stop time, elapsed duration and elapsed stop duration.
◆ Running()
bool Running | ( | ) | const |
Get whether the stopwatch is running.
- Returns
- True if the stopwatch is running.
◆ Start()
bool Start | ( | const bool | _reset = false | ) |
Start the stopwatch.
- Parameters
-
[in] _reset If true the stopwatch is reset first.
- Returns
- True if the the stopwatch was started. This will return false if the stopwatch was already running.
◆ StartTime()
clock::time_point StartTime | ( | ) | const |
Get the time when the stopwatch was started.
- Returns
- The time when stopwatch was started, or std::chrono::steady_clock::time_point::min() if the stopwatch has not been started.
◆ Stop()
bool Stop | ( | ) |
Stop the stopwatch.
- Returns
- True if the stopwatch was stopped. This will return false if the stopwatch is not running.
◆ StopTime()
clock::time_point StopTime | ( | ) | const |
Get the time when the stopwatch was last stopped.
- Returns
- The time when stopwatch was last stopped, or std::chrono::steady_clock::time_point::min() if the stopwatch has never been stopped.
The documentation for this class was generated from the following file: