ocra-recipes
Doxygen documentation for the ocra-recipes repository
Public Member Functions | Protected Attributes | List of all members
wocra::PerformanceRecorder Class Reference

To get and save time information to collect some data on performances. More...

#include <Performances.h>

Public Member Functions

 PerformanceRecorder ()
 
virtual ~PerformanceRecorder ()
 
double getCurrentTime ()
 
void initializeTime ()
 
void saveRelativeTime ()
 
double getRelativeTime ()
 
void saveTime (double t)
 
const std::list< double > & getSavedTime () const
 
void writeInStream (const std::string &headerName, std::ostream &outstream, bool addCommaAtEnd)
 

Protected Attributes

timeval tim
 
double _initTime
 
std::list< double > _record
 

Detailed Description

To get and save time information to collect some data on performances.

It can be used in two ways. First to save a timeline:

PerformanceRecorder perfRec; // create performance recorder
...
perfRec.initializeTime(); // initialize somewhere
for ( ... )
{
perfRec.saveRelativeTime(); // save time relatively the the call of initializeTime()
...
}

Or to save loop performances:

PerformanceRecorder perfRec; // create performance recorder
...
for ( ... )
{
perfRec.initializeTime(); // reset time at the beginning of the loop
...
perfRec.saveRelativeTime(); // save time at the end of the loop
}

Definition at line 65 of file wocra/include/wocra/Performances.h.

Constructor & Destructor Documentation

wocra::PerformanceRecorder::PerformanceRecorder ( )
inline

Create a performance recorder. It also initializes the internal initial time.

Definition at line 72 of file wocra/include/wocra/Performances.h.

virtual wocra::PerformanceRecorder::~PerformanceRecorder ( )
inlinevirtual

Destructor

Definition at line 77 of file wocra/include/wocra/Performances.h.

Member Function Documentation

double wocra::PerformanceRecorder::getCurrentTime ( )
inline

Get the current time.

It calls method "gettimeofday" and returns a value representing the current time of the day in second.

Definition at line 83 of file wocra/include/wocra/Performances.h.

double wocra::PerformanceRecorder::getRelativeTime ( )
inline

get the relative elapsed time since the time reference, i.e. the last call of initializeTime().

Definition at line 108 of file wocra/include/wocra/Performances.h.

const std::list< double >& wocra::PerformanceRecorder::getSavedTime ( ) const
inline

Get the list where are saved the relative times.

Definition at line 120 of file wocra/include/wocra/Performances.h.

void wocra::PerformanceRecorder::initializeTime ( )
inline

Initialize internal Zero time.

It calls method getCurrentTime() to get a time reference.

Definition at line 92 of file wocra/include/wocra/Performances.h.

void wocra::PerformanceRecorder::saveRelativeTime ( )
inline

Save the relative elapsed time since the time reference, i.e. the last call of initializeTime().

The value is saved in a list available with getSavedTime() const

Definition at line 100 of file wocra/include/wocra/Performances.h.

void wocra::PerformanceRecorder::saveTime ( double  t)
inline

Definition at line 112 of file wocra/include/wocra/Performances.h.

void wocra::PerformanceRecorder::writeInStream ( const std::string &  headerName,
std::ostream &  outstream,
bool  addCommaAtEnd 
)
inline

Save performances information in a output stream.

Parameters
headerNameThe name of the performance saved in the
outstreamthe output stream where to write the performances information
addCommaAtEndIf true, add a comma at the end of the stream. If false, it means that this is the end of the json file, nothing will be added after that, no comma is added.

Definition at line 130 of file wocra/include/wocra/Performances.h.

Member Data Documentation

double wocra::PerformanceRecorder::_initTime
protected

Definition at line 149 of file wocra/include/wocra/Performances.h.

std::list< double > wocra::PerformanceRecorder::_record
protected

Definition at line 151 of file wocra/include/wocra/Performances.h.

timeval wocra::PerformanceRecorder::tim
protected

Definition at line 147 of file wocra/include/wocra/Performances.h.


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