Stride Reference Manual  1.0
stride::util::Stopwatch< T > Class Template Reference

Provides a stopwatch interface to time: it accumulates time between start/stop pairs. More...

#include <Stopwatch.h>

Collaboration diagram for stride::util::Stopwatch< T >:
Collaboration graph

Public Types

typedef T TClock
 

Public Member Functions

 Stopwatch (std::string name="stopwatch", bool running=false)
 Constructor initializes stopwatch. More...
 
Stopwatchstart ()
 Starts stopwatch if it was stopped. More...
 
Stopwatchstop ()
 Stops the stopwatch if it was running. More...
 
Stopwatchreset ()
 Resets stopwatch i.e. stopwatch is stopped and time accumulator is cleared. More...
 
bool isRunning () const
 Reports whether stopwatch has been started. More...
 
std::string getName () const
 Return name of this stopwatch. More...
 
T::duration get () const
 Returns the accumulated value without altering the stopwatch state. More...
 
std::string toString () const
 Returns string representation of readout. More...
 

Private Attributes

T::duration m_accumulated
 
T::time_point m_last_start
 
std::string m_name
 
bool m_running
 

Detailed Description

template<typename T = std::chrono::system_clock>
class stride::util::Stopwatch< T >

Provides a stopwatch interface to time: it accumulates time between start/stop pairs.

Definition at line 33 of file Stopwatch.h.

Member Typedef Documentation

template<typename T = std::chrono::system_clock>
typedef T stride::util::Stopwatch< T >::TClock

Definition at line 35 of file Stopwatch.h.

Constructor & Destructor Documentation

template<typename T = std::chrono::system_clock>
stride::util::Stopwatch< T >::Stopwatch ( std::string  name = "stopwatch",
bool  running = false 
)
inline

Constructor initializes stopwatch.

Definition at line 38 of file Stopwatch.h.

References stride::util::Stopwatch< T >::m_last_start, and stride::util::Stopwatch< T >::m_running.

Member Function Documentation

template<typename T = std::chrono::system_clock>
Stopwatch& stride::util::Stopwatch< T >::start ( )
inline

Starts stopwatch if it was stopped.

Definition at line 46 of file Stopwatch.h.

References stride::util::Stopwatch< T >::m_last_start, and stride::util::Stopwatch< T >::m_running.

template<typename T = std::chrono::system_clock>
Stopwatch& stride::util::Stopwatch< T >::stop ( )
inline
template<typename T = std::chrono::system_clock>
Stopwatch& stride::util::Stopwatch< T >::reset ( )
inline

Resets stopwatch i.e. stopwatch is stopped and time accumulator is cleared.

Definition at line 64 of file Stopwatch.h.

References stride::util::Stopwatch< T >::m_accumulated, and stride::util::Stopwatch< T >::m_running.

template<typename T = std::chrono::system_clock>
bool stride::util::Stopwatch< T >::isRunning ( ) const
inline

Reports whether stopwatch has been started.

Definition at line 71 of file Stopwatch.h.

References stride::util::Stopwatch< T >::m_running.

template<typename T = std::chrono::system_clock>
std::string stride::util::Stopwatch< T >::getName ( ) const
inline

Return name of this stopwatch.

Definition at line 76 of file Stopwatch.h.

References stride::util::Stopwatch< T >::m_name.

template<typename T = std::chrono::system_clock>
T::duration stride::util::Stopwatch< T >::get ( ) const
inline

Returns the accumulated value without altering the stopwatch state.

Definition at line 81 of file Stopwatch.h.

References stride::util::Stopwatch< T >::m_accumulated, stride::util::Stopwatch< T >::m_last_start, and stride::util::Stopwatch< T >::m_running.

template<typename T = std::chrono::system_clock>
std::string stride::util::Stopwatch< T >::toString ( ) const
inline

Returns string representation of readout.

Definition at line 90 of file Stopwatch.h.

References stride::util::TimeToString::toColonString().

Member Data Documentation

template<typename T = std::chrono::system_clock>
T::duration stride::util::Stopwatch< T >::m_accumulated
private
template<typename T = std::chrono::system_clock>
T::time_point stride::util::Stopwatch< T >::m_last_start
private
template<typename T = std::chrono::system_clock>
std::string stride::util::Stopwatch< T >::m_name
private

Definition at line 112 of file Stopwatch.h.

Referenced by stride::util::Stopwatch< T >::getName().


The documentation for this class was generated from the following file: