Stride Reference Manual  - generated for commit 9643b11
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

using TClock = T
 

Public Member Functions

 Stopwatch (std::string name="stopwatch", bool running=false)
 Constructor initializes stopwatch. More...
 
Stopwatch & Start ()
 Starts stopwatch if it was stopped. More...
 
Stopwatch & Stop ()
 Stops the stopwatch if it was running. More...
 
Stopwatch & Reset ()
 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::steady_clock>
class stride::util::Stopwatch< T >

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

Definition at line 35 of file Stopwatch.h.

Member Typedef Documentation

template<typename T = std::chrono::steady_clock>
using stride::util::Stopwatch< T >::TClock = T

Definition at line 38 of file Stopwatch.h.

Constructor & Destructor Documentation

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

Constructor initializes stopwatch.

Definition at line 41 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::steady_clock>
Stopwatch& stride::util::Stopwatch< T >::Start ( )
inline

Starts stopwatch if it was stopped.

Definition at line 50 of file Stopwatch.h.

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

Referenced by stride::SimRunner::Run(), stride::SimRunner::SimRunner(), and stride::ControlHelper::~ControlHelper().

Here is the caller graph for this function:

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

Stops the stopwatch if it was running.

Definition at line 60 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.

Referenced by stride::SimRunner::Run(), and stride::ControlHelper::Shutdown().

Here is the caller graph for this function:

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

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

Definition at line 70 of file Stopwatch.h.

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

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

Reports whether stopwatch has been started.

Definition at line 78 of file Stopwatch.h.

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

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

Return name of this stopwatch.

Definition at line 81 of file Stopwatch.h.

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

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

Returns the accumulated value without altering the stopwatch state.

Definition at line 84 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.

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

Here is the caller graph for this function:

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

Returns string representation of readout.

Definition at line 94 of file Stopwatch.h.

References stride::util::Stopwatch< T >::Get(), and stride::util::TimeToString::ToColonString().

Referenced by stride::ControlHelper::Shutdown().

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

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

Definition at line 117 of file Stopwatch.h.

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


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