gatb.core-API-1.4.2
TimeInfo Class Reference

Tool for time statistics. More...

#include <TimeInfo.hpp>

Inheritance diagram for TimeInfo:
Inheritance graph

Public Member Functions

 TimeInfo ()
 
 TimeInfo (system::ITime &aTime)
 
virtual void start (const char *name)
 
virtual void stop (const char *name)
 
TimeInfooperator+= (TimeInfo &ti)
 
TimeInfooperator/= (size_t nb)
 
const std::map< std::string, u_int32_t > & getEntries ()
 
u_int32_t getEntryByKey (const std::string &key)
 
double get (const std::string &key)
 
virtual tools::misc::IPropertiesgetProperties (const std::string &root)
 
- Public Member Functions inherited from SmartPointer
void use ()
 
void forget ()
 
- Public Member Functions inherited from ISmartPointer
virtual ~ISmartPointer ()
 

Additional Inherited Members

- Protected Member Functions inherited from SmartPointer
 SmartPointer ()
 
virtual ~SmartPointer ()
 

Detailed Description

Tool for time statistics.

This class provides methods for getting time information between two execution points.

One can use a label for getting a specific time duration; it is possible later to get this duration by giving the label.

Example of use:

void foo ()
{
t.addEntry ("part1");
// do something here
t.stopEntry ("part1");
t.addEntry ("part2");
// do something here
t.stopEntry ("part2");
// now, we dump the duration of part1 and part2:
cout << "part1: " << t.getEntryByKey("part1") << " "
<< "part2: " << t.getEntryByKey("part2") << endl;
}

Constructor & Destructor Documentation

TimeInfo ( )

Default constructor.

TimeInfo ( system::ITime aTime)

Constructor taking a time factory.

Parameters
[in]aTime: the time factory to be used.

Member Function Documentation

double get ( const std::string &  key)
inline

Retrieve the duration for a given label in seconds

Parameters
[in]key: the label we want the duration for.
Returns
the duration.
const std::map< std::string, u_int32_t > & getEntries ( )

Provides (as a map) all got durations for each known label/

Returns
a map holding all retrieved timing information.
u_int32_t getEntryByKey ( const std::string &  key)

Retrieve the duration for a given label.

Parameters
[in]key: the label we want the duration for.
Returns
the duration.
tools::misc::IProperties * getProperties ( const std::string &  root)
virtual

Creates and return as a IProperties instance the whole timing information.

Parameters
[in]root: root name of the properties to be returned.
Returns
the created IProperties instance.
TimeInfo & operator+= ( TimeInfo ti)

Merge the content of the current time info with the provided one.

Parameters
[in]ti: info to merged.
TimeInfo & operator/= ( size_t  nb)

Didive the time (useful when gathered times from several threads).

Parameters
[in]nb: divisor.
void start ( const char *  name)
virtual

Get the start time for a given label.

Parameters
[in]name: the label
void stop ( const char *  name)
virtual

Get the stop time for a given label.

Parameters
[in]name: the label

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