#include <TimingProfile.h>

Inherits Loggable.

Classes

struct  Timer
 

Public Member Functions

 TimingProfile ()
 
 TimingProfile (Logger *logger)
 
virtual ~TimingProfile ()
 
void Clear ()
 
void Reset (const std::string &label)
 
void Start (const std::string &label)
 
void Stop (const std::string &label)
 
double GetElapsedTime_s (const std::string &label)
 
void Print (const std::string &label)
 
template<typename Duration >
Duration::rep GetElapsedTime (const std::string &label)
 
- Public Member Functions inherited from Loggable
 Loggable ()
 
 Loggable (Logger *log)
 
virtual ~Loggable ()
 
virtual LoggerGetLogger () const
 
virtual void Debug (std::string const &msg, std::string const &origin=empty) const
 
virtual void Debug (std::stringstream &msg, std::string const &origin=empty) const
 
virtual void Debug (std::ostream &msg, std::string const &origin=empty) const
 
virtual void Info (std::string const &msg, std::string const &origin=empty) const
 
virtual void Info (std::stringstream &msg, std::string const &origin=empty) const
 
virtual void Info (const std::stringstream &msg, std::string const &origin=empty) const
 
virtual void Info (std::ostream &msg, std::string const &origin=empty) const
 
virtual void Warning (std::string const &msg, std::string const &origin=empty) const
 
virtual void Warning (std::stringstream &msg, std::string const &origin=empty) const
 
virtual void Warning (std::ostream &msg, std::string const &origin=empty) const
 
virtual void Error (std::string const &msg, std::string const &origin=empty) const
 
virtual void Error (std::stringstream &msg, std::string const &origin=empty) const
 
virtual void Error (std::ostream &msg, std::string const &origin=empty) const
 
virtual void Fatal (std::string const &msg, std::string const &origin=empty) const
 
virtual void Fatal (std::stringstream &msg, std::string const &origin=empty) const
 
virtual void Fatal (std::ostream &msg, std::string const &origin=empty) const
 

Private Types

enum  State { State::Ready, State::Running, State::Ran }
 
using Clock = std::chrono::high_resolution_clock
 

Private Attributes

std::map< std::string, Timerm_timers
 
std::stringstream m_ss
 

Additional Inherited Members

- Static Public Attributes inherited from Loggable
static const std::string empty
 
- Protected Attributes inherited from Loggable
Loggerm_Logger
 

Member Typedef Documentation

◆ Clock

using TimingProfile::Clock = std::chrono::high_resolution_clock
private

Member Enumeration Documentation

◆ State

enum TimingProfile::State
strongprivate
Enumerator
Ready 
Running 
Ran 

Constructor & Destructor Documentation

◆ TimingProfile() [1/2]

TimingProfile::TimingProfile ( )
inline

◆ TimingProfile() [2/2]

TimingProfile::TimingProfile ( Logger logger)
inline

◆ ~TimingProfile()

virtual TimingProfile::~TimingProfile ( )
inlinevirtual

Member Function Documentation

◆ Clear()

void TimingProfile::Clear ( )

◆ GetElapsedTime()

template<typename Duration >
Duration::rep TimingProfile::GetElapsedTime ( const std::string &  label)
inline

Returns the elapsed time for a particular timer

◆ GetElapsedTime_s()

double TimingProfile::GetElapsedTime_s ( const std::string &  label)

Returns the total elapsed time in seconds to three decimal places. If the timer is running, this function returns the elapsed time up until now. If the timer has been stopped, this function returns the elapsed time between the start and stop. If the timer hasn't been run yet (Ready state), this function returns 0.

◆ Print()

void TimingProfile::Print ( const std::string &  label)

Prints the time from a call to Profile to console If nullptr is passed, all labels will be computed and printed

◆ Reset()

void TimingProfile::Reset ( const std::string &  label)

Resets the timer, this can have different effects based on the state of the timer: 1) Ready - No effect 2) Running - Resets the elapsed time to zero and continues running 3) Ran - Resets the elapsed time to zero and places the timer back into the Ready state

◆ Start()

void TimingProfile::Start ( const std::string &  label)

Starts the timer. Calling Start while the timer is running will reset its elapsed time. Calling Start after the timer has been started and stopped will reset its elapsed time, it does not pause and unpause the running elapsed time.

◆ Stop()

void TimingProfile::Stop ( const std::string &  label)

Stops the timer, elapsed time will remain constant until calling Reset or Start

Member Data Documentation

◆ m_ss

std::stringstream TimingProfile::m_ss
private

◆ m_timers

std::map<std::string, Timer> TimingProfile::m_timers
private