Main Page | Class Hierarchy | Class List | File List | Class Members

Resources Class Reference

#include <Resources.h>

List of all members.

Public Member Functions

 Resources (bool max=false)
void start ()
void record ()
void stop ()
void resume (bool countBreakResources=false)
const timeval userTime () const
const timeval systemTime () const
const timeval totalTime () const
const timeval realTime () const
long memory () const
long text () const
long data () const
long stack () const
long minorPageFaults () const
long majorPageFaults () const
long swaps () const
long inputBlocks () const
long outputBlocks () const
long messagesSent () const
long messagesReceived () const
long signalsReceived () const
long voluntaryContextSwitches () const
long involuntaryContextSwitches () const
wostream & print (wostream &wos) const

Static Public Member Functions

void add (const timeval &time1, const timeval &time2, timeval &result)
 Add two timeval structures.
void substract (const timeval &final, const timeval &initial, timeval &result)
 Substract two timeval structures.
int compare (const timeval &t1, const timeval &t2)
 Compare two timeval structures. t1<t2:-1, t1==t2:0, t1>t2:1.

Protected Types

enum  state_t { Started, Stopped }
 The type of state this object might be in.

Protected Member Functions

void read (timeval &timeStamp, rusage &resourceUsage, bool initialReading)
 Get the time and resource usage from the operating system.

Static Protected Member Functions

void move (timeval &initial, timeval &final, timeval &newFinal)
 Translate [initial-final] to [newInitial-newFinal].
wostream & printTime (wostream &wos, const timeval &tv)

Friends

CSP_API wostream & operator<< (wostream &wos, const Resources &resources)


Detailed Description

This class is used to compute the time elapsed & resource usage. The following diagram explains the way this object should be used.

+->>>-+ +->>>-+ | | | | | | | | | | | | start()--<<<--->>>--record()----->>>-----stop() | | | | | | | ^ | | | | ^ | | | | ^ | | | | | | | | +-----<<<-----resume()--<<<--->>>--+ | | | +-----------<<<------------------>>>----------+

FIXME: The code works per process, not per thread. FIXME: Many attributes are not implemented for Windows. Even Linux doesn't seem to support all of them.


Constructor & Destructor Documentation

Resources::Resources bool  max = false  ) 
 

Constructor. If `max' is false, the object will be initialized and resource usage recording will start. Otherwise all the resource usage fields will be initialized to reflect a maximum resource usage and the object will be left in a stopped state. This is useful when using the object as an initial upper bound on resources.


Member Function Documentation

wostream & Resources::print wostream &  wos  )  const
 

Print resource gathering results at the given stream.

Parameters:
wos the output stream to print to.
Returns:
the given stream.

const timeval Resources::realTime  )  const
 

Return the wall time elapsed between the last calls to start() and record().

void Resources::record  ) 
 

Record resource usage at the time of call. All calls requesting various resource usage numbers will report the numbers at the time of the last call to record() or stop().

void Resources::resume bool  countBreakResources = false  ) 
 

Resume recording resource usage. Resource usage between calls to stop() and resume() is substracted from the total if `countBreakResources' is false (default). resume() can only be called after stop().

void Resources::stop  ) 
 

Stop recording resource usage. All calls requesting various resource usage numbers will report the numbers at the time of the last call to record() or stop().

const timeval Resources::systemTime  )  const
 

Return the system time spent on behalf of this process between the last calls to start() and record().

const timeval Resources::totalTime  )  const
 

Return the sum of the system and user time spent on behalf of this process between the last calls to start() and record().

const timeval Resources::userTime  )  const
 

Return the user time spent on behalf of this process between the last calls to start() and record().


The documentation for this class was generated from the following files:
Generated on Wed May 25 12:21:21 2005 for csp.kdevelop by  doxygen 1.3.9.1