MultiAgentDecisionProcess
Timing Class Reference

Timing provides a simple way of timing code. More...

#include <Timing.h>

Classes

struct  Times
 Stores the start and end of a timespan, in clock cycles. More...
 

Public Member Functions

void AddEvent (const std::string &id, clock_t duration)
 Adds event of certain duration, e.g., an external program call. More...
 
std::vector< double > GetEventDurations (const std::string &id) const
 Returns all stored durations (in s) for a particular event. More...
 
std::vector< double > GetRunningEventDurations (const std::string &id) const
 Returns how long ago (in s) a particular event has been started. More...
 
void Load (const std::string &filename)
 Load timing info from file filename. More...
 
void Print () const
 Print stored timing info. More...
 
void PrintSummary () const
 Sums data and prints out a summary. More...
 
void Save (const std::string &filename) const
 Save collected timing info to file filename. More...
 
void Save (std::ofstream &of) const
 Save collected timing info to ofstream of. More...
 
void Start (const std::string &id)
 Start to time an event identified by id. More...
 
void Stop (const std::string &id)
 Stop to time an event identified by id. More...
 
 Timing ()
 (default) Constructor More...
 
 ~Timing ()
 Destructor. More...
 

Private Member Functions

double ClockToSeconds (clock_t clockTicks) const
 
clock_t GetCpuTime () const
 
void Stop (const std::string &id, clock_t duration)
 

Private Attributes

clock_t _m_timeAtInitialization
 The clock cycle at which the class is initialized. More...
 
std::map< std::string,
std::vector< Times > > 
_m_timesMap
 Keeps track of timing info. More...
 

Detailed Description

Timing provides a simple way of timing code.


Class Documentation

struct Timing::Times

Stores the start and end of a timespan, in clock cycles.

Class Members
clock_t end
bool hasEnded
clock_t start

Constructor & Destructor Documentation

Timing::Timing ( )

(default) Constructor

Timing::~Timing ( )

Destructor.

Member Function Documentation

void Timing::AddEvent ( const std::string &  id,
clock_t  duration 
)

Adds event of certain duration, e.g., an external program call.

double Timing::ClockToSeconds ( clock_t  clockTicks) const
private
clock_t Timing::GetCpuTime ( ) const
private
vector< double > Timing::GetEventDurations ( const std::string &  id) const

Returns all stored durations (in s) for a particular event.

Referenced by AlphaVectorPlanning::Prune().

vector< double > Timing::GetRunningEventDurations ( const std::string &  id) const

Returns how long ago (in s) a particular event has been started.

void Timing::Load ( const std::string &  filename)

Load timing info from file filename.

References Timing::Times::end, Timing::Times::hasEnded, and Timing::Times::start.

void Timing::Print ( ) const

Print stored timing info.

void Timing::PrintSummary ( ) const

Sums data and prints out a summary.

Referenced by TreeIncPruneBGPlanner::BackupStage(), and QBGPlanner_TreeIncPruneBnB::BackupStage().

void Timing::Save ( const std::string &  filename) const

Save collected timing info to file filename.

void Timing::Save ( std::ofstream &  of) const

Save collected timing info to ofstream of.

void Timing::Start ( const std::string &  id)
void Timing::Stop ( const std::string &  id,
clock_t  duration 
)
private
void Timing::Stop ( const std::string &  id)

Stop to time an event identified by id.

Member Data Documentation

clock_t Timing::_m_timeAtInitialization
private

The clock cycle at which the class is initialized.

std::map<std::string, std::vector<Times> > Timing::_m_timesMap
private

Keeps track of timing info.