Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

PsTimerController< ControleurAncetre > Class Template Reference

This template controler times the time it takes to simulate the virtual world between 2 dates, specified with the second and third configuration parameter of the controller. More...

#include <PsTimerController.h>

Inheritance diagram for PsTimerController< ControleurAncetre >:

Inheritance graph
[legend]
List of all members.

Public Methods

 PsTimerController (PsObjectDescriptor &initialObjects, const PsDate &initialDate)
 constructor finding the sampling interval

 PsTimerController (PsObjectDescriptor &initialObjects, const PsDate &initialDate, int argc, char *argv[])
 constructor finding the sampling interval, to use with the pvm familly of constructors

virtual ~PsTimerController ()
 destustor : print information to standard out

virtual void compute ()
 redefine compute to start and stop the timer


Protected Attributes

int _numberOfSamples
PsDate _startSamplingDate
PsDate _endSamplingDate
time_t dateReelleDebut
time_t dateReelleFin
timeval _dateReelleDebut
timeval _dateReelleFin

Detailed Description

template<typename ControleurAncetre>
class PsTimerController< ControleurAncetre >

This template controler times the time it takes to simulate the virtual world between 2 dates, specified with the second and third configuration parameter of the controller.

For example to time between the first and second one would specify {verbatim} root { ... UserParams { TimeFrom 1000 TimeUntil 2000 } } {verbatim}

Author:
David Margery
Version:
1.0

Definition at line 43 of file PsTimerController.h.


Constructor & Destructor Documentation

template<typename ControleurAncetre>
PsTimerController< ControleurAncetre >::PsTimerController PsObjectDescriptor   initialObjects,
const PsDate   initialDate
 

constructor finding the sampling interval

Definition at line 76 of file PsTimerController.h.

References PsTimerController< ControleurAncetre >::_endSamplingDate, PsTimerController< ControleurAncetre >::_startSamplingDate, PsConfigurationParameterDescriptor::getAssociatedString(), PsConfigurationParameterDescriptor::getSubDescriptorByName(), PsController::initialSimulationDate, and PsDate.

00079    :  ControleurAncetre(initialObjects, initialDate),
00080       _startSamplingDate ( initialDate ),
00081       _endSamplingDate ( initialDate+1000 )       
00082      
00083 {
00084    if (getConfigurationParameters() != NULL )
00085       {
00086          const PsConfigurationParameterDescriptor * param = getConfigurationParameters()->getSubDescriptorByName("TimeFrom") ;
00087          if ( param != NULL )
00088             {
00089                _startSamplingDate=atoi(param->getAssociatedString().c_str() ) ;
00090             }
00091 
00092          param = getConfigurationParameters()->getSubDescriptorByName("TimeUntil") ;
00093          if ( param != NULL )
00094             {
00095                _endSamplingDate = atoi(param->getAssociatedString().c_str()  ) ;
00096             }
00097       }
00098 
00099    if (_startSamplingDate>_endSamplingDate) 
00100       {
00101          cout<<"PsTimerController< >::WARNING : sampling dates dont make an interval"<<endl;
00102          cout<<"PsTimerController< >::WARNING : default sampling dates used "<<endl; 
00103          _startSamplingDate=PsController::initialSimulationDate;
00104          _endSamplingDate=PsController::initialSimulationDate+1000;            
00105       }

template<typename ControleurAncetre>
PsTimerController< ControleurAncetre >::PsTimerController PsObjectDescriptor   initialObjects,
const PsDate   initialDate,
int    argc,
char *    argv[]
 

constructor finding the sampling interval, to use with the pvm familly of constructors

Definition at line 108 of file PsTimerController.h.

References PsTimerController< ControleurAncetre >::_endSamplingDate, PsTimerController< ControleurAncetre >::_startSamplingDate, PsConfigurationParameterDescriptor::getAssociatedString(), PsConfigurationParameterDescriptor::getSubDescriptorByName(), PsController::initialSimulationDate, and PsDate.

00113    :  ControleurAncetre(initialObjects, initialDate, argc, argv),
00114       _startSamplingDate ( initialDate ),
00115       _endSamplingDate ( initialDate+1000 )       
00116      
00117 {
00118    if (getConfigurationParameters() != NULL )
00119       {
00120          const PsConfigurationParameterDescriptor * param = getConfigurationParameters()->getSubDescriptorByName("TimeFrom") ;
00121          if ( param != NULL )
00122             {
00123                _startSamplingDate=atoi(param->getAssociatedString().c_str() ) ;
00124             }
00125 
00126          param = getConfigurationParameters()->getSubDescriptorByName("TimeUntil") ;
00127          if ( param != NULL )
00128             {
00129                _endSamplingDate = atoi(param->getAssociatedString().c_str()  ) ;
00130             }
00131       }
00132 
00133    if (_startSamplingDate>_endSamplingDate) 
00134       {
00135          cout<<"PsTimerController< >::WARNING : sampling dates dont make an interval"<<endl;
00136          cout<<"PsTimerController< >::WARNING : default sampling dates used "<<endl; 
00137          _startSamplingDate=PsController::initialSimulationDate;
00138          _endSamplingDate=PsController::initialSimulationDate+1000;            
00139       }

template<typename ControleurAncetre>
PsTimerController< ControleurAncetre >::~PsTimerController   [virtual]
 

destustor : print information to standard out

Definition at line 147 of file PsTimerController.h.

References PsTimerController< ControleurAncetre >::_dateReelleDebut, PsTimerController< ControleurAncetre >::_dateReelleFin, PsTimerController< ControleurAncetre >::_endSamplingDate, PsTimerController< ControleurAncetre >::_startSamplingDate, PsTimerController< ControleurAncetre >::dateReelleDebut, and PsTimerController< ControleurAncetre >::dateReelleFin.

00149 {
00150    cout<<"Simulated time between second "<<_startSamplingDate/1000<<" and second "<<_endSamplingDate/1000
00151        <<" was computed in  "<<dateReelleFin - dateReelleDebut<<" clock wall seconds"<<endl;
00152    if (_dateReelleFin.tv_usec - _dateReelleDebut.tv_usec<0 ) {
00153       cout<<"More precisly "<<_dateReelleFin.tv_sec - _dateReelleDebut.tv_sec-1<<" seconds and "
00154           <<_dateReelleFin.tv_usec - _dateReelleDebut.tv_usec+1000000<<" microseconds"<<endl;
00155    }
00156    else {
00157       cout<<"More precisly "<<_dateReelleFin.tv_sec - _dateReelleDebut.tv_sec<<" seconds and "
00158           <<_dateReelleFin.tv_usec - _dateReelleDebut.tv_usec<<" microseconds"<<endl;
00159    }


Member Function Documentation

template<typename ControleurAncetre>
void PsTimerController< ControleurAncetre >::compute   [virtual]
 

redefine compute to start and stop the timer

Reimplemented in PsPvmBenchController< APvmController >, PsBenchController< BenchedController >, PsBenchController< PsMultiThreadedPvmController >, PsBenchController< PsMultiThreadedController >, PsBenchController< APvmController >, and PsPvmBenchController< PsMultiThreadedPvmController >.

Definition at line 162 of file PsTimerController.h.

References PsTimerController< ControleurAncetre >::_dateReelleDebut, PsTimerController< ControleurAncetre >::_dateReelleFin, PsTimerController< ControleurAncetre >::_endSamplingDate, PsTimerController< ControleurAncetre >::_startSamplingDate, PsTimerController< ControleurAncetre >::dateReelleDebut, PsTimerController< ControleurAncetre >::dateReelleFin, and PsSystemEventIdentifier::MaskStop.

00164 {
00165    //initialisation des compteurs du pas de calcul
00166    if ((_startSamplingDate- _stepPeriod <_date)&&(_date<=_startSamplingDate)) {
00167       dateReelleDebut = time(NULL) ;
00168       gettimeofday(&_dateReelleDebut, NULL);
00169    }
00170    if ((_endSamplingDate<=_date)&&(_date<_endSamplingDate + _stepPeriod)) 
00171       {
00172          dateReelleFin = time(NULL) ;
00173          gettimeofday(&_dateReelleFin, NULL);
00174          sendEvent (getController(), PsSystemEventIdentifier::MaskStop ) ;
00175       }
00176    ControleurAncetre::compute ();


Member Data Documentation

template<typename ControleurAncetre>
timeval PsTimerController< ControleurAncetre >::_dateReelleDebut [protected]
 

Definition at line 69 of file PsTimerController.h.

Referenced by PsTimerController< ControleurAncetre >::compute(), and PsTimerController< ControleurAncetre >::~PsTimerController().

template<typename ControleurAncetre>
timeval PsTimerController< ControleurAncetre >::_dateReelleFin [protected]
 

Definition at line 70 of file PsTimerController.h.

Referenced by PsTimerController< ControleurAncetre >::compute(), and PsTimerController< ControleurAncetre >::~PsTimerController().

template<typename ControleurAncetre>
PsDate PsTimerController< ControleurAncetre >::_endSamplingDate [protected]
 

Reimplemented in PsBenchController< BenchedController >, PsBenchController< PsMultiThreadedPvmController >, PsBenchController< PsMultiThreadedController >, and PsBenchController< APvmController >.

Definition at line 66 of file PsTimerController.h.

Referenced by PsTimerController< ControleurAncetre >::compute(), PsTimerController< ControleurAncetre >::PsTimerController(), and PsTimerController< ControleurAncetre >::~PsTimerController().

template<typename ControleurAncetre>
int PsTimerController< ControleurAncetre >::_numberOfSamples [protected]
 

Reimplemented in PsBenchController< BenchedController >, PsBenchController< PsMultiThreadedPvmController >, PsBenchController< PsMultiThreadedController >, and PsBenchController< APvmController >.

Definition at line 64 of file PsTimerController.h.

template<typename ControleurAncetre>
PsDate PsTimerController< ControleurAncetre >::_startSamplingDate [protected]
 

Reimplemented in PsBenchController< BenchedController >, PsBenchController< PsMultiThreadedPvmController >, PsBenchController< PsMultiThreadedController >, and PsBenchController< APvmController >.

Definition at line 65 of file PsTimerController.h.

Referenced by PsTimerController< ControleurAncetre >::compute(), PsTimerController< ControleurAncetre >::PsTimerController(), and PsTimerController< ControleurAncetre >::~PsTimerController().

template<typename ControleurAncetre>
time_t PsTimerController< ControleurAncetre >::dateReelleDebut [protected]
 

Definition at line 67 of file PsTimerController.h.

Referenced by PsTimerController< ControleurAncetre >::compute(), and PsTimerController< ControleurAncetre >::~PsTimerController().

template<typename ControleurAncetre>
time_t PsTimerController< ControleurAncetre >::dateReelleFin [protected]
 

Definition at line 68 of file PsTimerController.h.

Referenced by PsTimerController< ControleurAncetre >::compute(), and PsTimerController< ControleurAncetre >::~PsTimerController().


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

Documentation generated on Mon Nov 25 15:26:31 2002

Generated with doxygen 1.2.12 by Dimitri van Heesch ,   1997-2001