rasdaman API
Public Member Functions | List of all members
RMTimer Class Reference

Module: { raslib}. More...

#include <rmdebug.hh>

Inheritance diagram for RMTimer:
RM_Class

Public Member Functions

 RMTimer (const char *newClass, const char *newFunc, int newBmLevel=0)
 constructor, initializes members and starts timer. More...
 
 ~RMTimer ()
 destructor, calls stop(). More...
 
void setOutput (int newOutput)
 switch output on RMInit::bmOut on and off. More...
 
void pause ()
 pauses timer. More...
 
void resume ()
 resumes timer. More...
 
void start ()
 resets timer. More...
 
void stop ()
 prints time spent if output is TRUE. More...
 
int getTime ()
 delivers current time count. More...
 

Detailed Description

Module: { raslib}.

RMTimer is not strictly part of RasLib. It is a class used for taking timing measurements if configuring with –benchmark-enabled. One way of using it is to put the following at the beginning of a function:

{ RMTIMER("className", "functionName");}

If RMANBENCHMARK is defined this is expanded to:

{ RMTimer localRMTimer = RMTimer("className", "functionName");}

Time is taken between this line and exiting the block where this line was. For more elaborate timing measurements an RMTimer object can be used directly. All timing information is stored in the object, so multiple RMTimer objects can be used at the same time.

If output is generated on RMInit::bmOut depends on the flag { output} and the benchmark level. Output is generated if { output} is TRUE and { bmLevel} is lower than the global benchmark level stored in RManBenchmark. The flag { output} can be changed with setOutput(). The function start() sets { output} to TRUE, stop() sets { output} to FALSE.

{ Important}: If a RMTimer is used as a static variable, it must be ensured that no output is generated in the destructor either by calling stop() or by manually setting { output} to FALSE using setOutput() before termination of the program. The reason is that potentially RMInit::bmOut may be destructed before the RMTimer destructor is called possibly causing a crash.

Constructor & Destructor Documentation

RMTimer::RMTimer ( const char *  newClass,
const char *  newFunc,
int  newBmLevel = 0 
)
inline

constructor, initializes members and starts timer.

RMTimer::~RMTimer ( )
inline

destructor, calls stop().

The parameters newClass and newFunc have to be string literals. Just a pointer to them is stored. No output is generated if RManBenchmark < newBmLevel.

Member Function Documentation

int RMTimer::getTime ( )
inline

delivers current time count.

Time spent is the time since construction or last start() excluding the times between pause() and resume().

void RMTimer::pause ( )
inline

pauses timer.

If newOutoutput is FALSE no output is created on RMInit::bmOut on the following calls to stop() and ~RMTimer() until the next start().

void RMTimer::resume ( )
inline

resumes timer.

void RMTimer::setOutput ( int  newOutput)
inline

switch output on RMInit::bmOut on and off.

void RMTimer::start ( )
inline

resets timer.

void RMTimer::stop ( )
inline

prints time spent if output is TRUE.

Also switches output to RMInit::bmOut on again.


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