DART 6.13.2
|
Simple stopwatch implementation. More...
#include <Stopwatch.hpp>
Public Member Functions | |
Stopwatch (bool start=true) | |
Constructor. | |
~Stopwatch () | |
Destructor. | |
bool | isStarted () const |
Returns whether the stopwatch is started. | |
void | start () |
Starts the stopwatch. | |
void | stop () |
Stops the stopwatch. | |
void | reset () |
Resets the stopwatch. | |
double | elapsedS () const |
Returns the elapsed time in seconds. | |
double | elapsedMS () const |
Returns the elapsed time in milliseconds. | |
double | elapsedUS () const |
Returns the elapsed time in microseconds. | |
double | elapsedNS () const |
Returns the elapsed time in nanoseconds. | |
void | print (std::ostream &os=std::cout) const |
Prints state of the stopwatch. | |
Private Member Functions | |
Stopwatch (const Stopwatch &)=delete | |
Stopwatch (Stopwatch &&)=delete | |
Stopwatch & | operator= (const Stopwatch &)=delete |
Stopwatch & | operator= (Stopwatch &&)=delete |
UnitType | duration () const |
Returns the duration. | |
Private Attributes | |
ClockType::time_point | mStart |
The start time. | |
UnitType | mElapsed |
The elapsed time. | |
bool | mPaused |
Whether the stopwatch is paused. | |
Friends | |
template<typename T , typename U > | |
std::ostream & | operator<< (std::ostream &os, const Stopwatch< T, U > &sw) |
Prints state of the stopwatch. | |
Simple stopwatch implementation.
|
explicit |
Constructor.
[in] | start | (optional) Whether to start the stopwatch on construction |
dart::common::Stopwatch< UnitType, ClockType >::~Stopwatch | ( | ) |
Destructor.
|
privatedelete |
|
privatedelete |
|
private |
Returns the duration.
double dart::common::Stopwatch< UnitType, ClockType >::elapsedMS | ( | ) | const |
Returns the elapsed time in milliseconds.
double dart::common::Stopwatch< UnitType, ClockType >::elapsedNS | ( | ) | const |
Returns the elapsed time in nanoseconds.
double dart::common::Stopwatch< UnitType, ClockType >::elapsedS | ( | ) | const |
Returns the elapsed time in seconds.
double dart::common::Stopwatch< UnitType, ClockType >::elapsedUS | ( | ) | const |
Returns the elapsed time in microseconds.
bool dart::common::Stopwatch< UnitType, ClockType >::isStarted | ( | ) | const |
Returns whether the stopwatch is started.
|
privatedelete |
|
privatedelete |
void dart::common::Stopwatch< UnitType, ClockType >::print | ( | std::ostream & | os = std::cout | ) | const |
Prints state of the stopwatch.
void dart::common::Stopwatch< UnitType, ClockType >::reset | ( | ) |
Resets the stopwatch.
Sets the start time to current time and the accumulated elasped time to zero.
void dart::common::Stopwatch< UnitType, ClockType >::start | ( | ) |
Starts the stopwatch.
void dart::common::Stopwatch< UnitType, ClockType >::stop | ( | ) |
Stops the stopwatch.
|
friend |
Prints state of the stopwatch.
|
private |
The elapsed time.
|
private |
Whether the stopwatch is paused.
|
private |
The start time.