The Stopwatch class measures elapsed time between instantiation (or a call to start) and a call to stop. More...
#include <Stopwatch.h>
Public Member Functions | |
Stopwatch (bool start_running=true) | |
Constructor; if start_running is true then the Stopwatch is started immediately. More... | |
void | start () |
Starts the Stopwatch. More... | |
void | stop () |
Stops the Stopwatch. More... | |
void | reset () |
Resets the Stopwatch. More... | |
double | elapsed () |
Returns the elapsed time. More... | |
int64_t | elapsed_millis () |
Returns elapsed time in milliseconds. More... | |
Private Attributes | |
bool | m_running |
Flag whether the Stopwatch is currently running. More... | |
std::chrono::steady_clock::time_point | start_time |
The start time. More... | |
std::chrono::steady_clock::duration | elapsed_time {0} |
The elapsed time. More... | |
The Stopwatch class measures elapsed time between instantiation (or a call to start) and a call to stop.
Definition at line 40 of file Stopwatch.h.
|
inline |
Constructor; if start_running is true then the Stopwatch is started immediately.
Definition at line 44 of file Stopwatch.h.
|
inline |
Returns the elapsed time.
Can be called while the Stopwatch is running; in this case the Stopwatch will continue to run.
Definition at line 72 of file Stopwatch.h.
|
inline |
Returns elapsed time in milliseconds.
Definition at line 84 of file Stopwatch.h.
|
inline |
Resets the Stopwatch.
Definition at line 66 of file Stopwatch.h.
|
inline |
Starts the Stopwatch.
Definition at line 50 of file Stopwatch.h.
|
inline |
Stops the Stopwatch.
Has no effect if the Stopwatch was not running.
Definition at line 58 of file Stopwatch.h.
|
private |
The elapsed time.
Definition at line 100 of file Stopwatch.h.
|
private |
Flag whether the Stopwatch is currently running.
Definition at line 94 of file Stopwatch.h.
|
private |
The start time.
Definition at line 97 of file Stopwatch.h.