#include <PsBenchController.h>
Inheritance diagram for PsBenchController< BenchedController >:


Public Methods | |
| PsBenchController (PsObjectDescriptor &scenario, const PsDate &initialDate) | |
| constructor for standard controllers | |
| PsBenchController (PsObjectDescriptor &scenario, const PsDate &initialDate, int argc, char *argv[]) | |
| constructor for distributed controllers | |
| virtual | ~PsBenchController () |
| destructor it is the destructor that writes the bench results to a file | |
| virtual PsnScheduler * | createScheduler () |
| create a scheduler than can bench stuff | |
| virtual void | advanceSimulatedDate () |
| redefine advanceSimuledDate so that the sample index is incremented | |
| PsBenchController (PsObjectDescriptor &scenario, const PsDate &initialDate, string nonFichRes) | |
| constructor | |
| virtual | ~PsBenchController () |
| destructor it is the destructor that writes the bench results to a file | |
| virtual void | compute () |
| redefine compute so that time is mesured | |
| virtual void | init () |
| create data strcutures to hold benching information | |
| virtual PsnScheduler * | createScheduler () |
| create a scheduler than can bench stuff | |
Protected Methods | |
| virtual void | printToStream (ostream &out) |
| write the sampled result to a stream | |
| virtual void | flushResults () |
| writes the sampled results to a file if a filename was given, to stdout otherwise | |
Protected Attributes | |
| PsString | _resultFilename |
| the file name to which the results must be written | |
| int | _sampleIndex |
| index of the current sample | |
| ofstream * | _file |
| a pointer to the file to which is written all data collected | |
| long * | _stepDurationTab |
| a table recording the time it took to calculated each simulation step | |
| long * | _slowedDownStepDurationTab |
| a table recording the time, it took to calculate and wait for each simualtion step | |
| unsigned int | _numberOfSamples |
| the number of samples to take | |
| PsDate | _startSamplingDate |
| the date at wich sampling starts | |
| PsDate | _endSamplingDate |
| the date at wich sampling finishes | |
| ofstream * | _file |
| a pointer to the file to which is written all data collected | |
Definition at line 36 of file PsBenchController.h.
|
||||||||||||||||
|
constructor for standard controllers
Definition at line 82 of file PsBenchController.h. References PsBenchController< BenchedController >::_file, PsBenchController< BenchedController >::_resultFilename, PsConfigurationParameterDescriptor::getAssociatedString(), PsSimulatedObject::getConfigurationParameters(), PsString::getCString(), PsConfigurationParameterDescriptor::getSubDescriptorByName(), and PsDate.
00083 : 00084 PsTimerController<BenchedController>(scenario, initialDate), 00085 _resultFilename (""), 00086 _sampleIndex ( -1 ), 00087 _file (NULL ) 00088 { 00089 if (getConfigurationParameters() != NULL ) 00090 { 00091 const PsConfigurationParameterDescriptor * param = getConfigurationParameters()->getSubDescriptorByName("BenchResultFile") ; 00092 if ( param != NULL ) 00093 { 00094 _resultFilename = param->getAssociatedString() ; 00095 _file = new ofstream ( _resultFilename.getCString() ); 00096 assert ( _file->good() ) ; 00097 } 00098 } |
|
||||||||||||||||||||||||
|
constructor for distributed controllers
Definition at line 101 of file PsBenchController.h. References PsBenchController< BenchedController >::_file, PsBenchController< BenchedController >::_resultFilename, PsConfigurationParameterDescriptor::getAssociatedString(), PsSimulatedObject::getConfigurationParameters(), PsString::getCString(), PsConfigurationParameterDescriptor::getSubDescriptorByName(), and PsDate.
00103 : PsTimerController<BenchedController>(scenario, initialDate, argc, argv), 00104 _resultFilename (""), 00105 _sampleIndex ( 0 ), 00106 _file (NULL ) 00107 { 00108 if (getConfigurationParameters() != NULL ) 00109 { 00110 const PsConfigurationParameterDescriptor * param = getConfigurationParameters()->getSubDescriptorByName("BenchResultFile") ; 00111 if ( param != NULL ) 00112 { 00113 _resultFilename = param->getAssociatedString() ; 00114 _file = new ofstream ( _resultFilename.getCString() ); 00115 assert ( _file->good() ) ; 00116 } 00117 } |
|
|||||||||
|
destructor it is the destructor that writes the bench results to a file
Definition at line 120 of file PsBenchController.h. References PsBenchController< BenchedController >::_file, and PsController::_scheduler.
00122 {
00123 // delete the scheduler because it has a pointer to the file we opened
00124 if ( _scheduler != NULL )
00125 {
00126 delete _scheduler ;
00127 _scheduler = NULL ;
00128 }
00129
00130 if ( _file != NULL )
00131 {
00132 _file->close() ;
00133 delete _file ;
00134 _file = NULL ;
00135 }
|
|
||||||||||||||||||||
|
constructor
|
|
|||||||||
|
destructor it is the destructor that writes the bench results to a file
|
|
|||||||||
|
redefine advanceSimuledDate so that the sample index is incremented
Reimplemented from PsController. Definition at line 165 of file PsBenchController.h. References PsController::_date, PsBenchController< BenchedController >::_endSamplingDate, PsBenchController< BenchedController >::_sampleIndex, and PsBenchController< BenchedController >::_startSamplingDate.
00167 {
00168 if ( (_date >= _startSamplingDate) &&
00169 (_date <= _endSamplingDate) )
00170 {
00171 ++_sampleIndex ;
00172 }
00173 PsTimerController<BenchedController>::advanceSimulatedDate() ;
|
|
|||||||||
|
redefine compute so that time is mesured
Reimplemented from PsController. Reimplemented in PsPvmBenchController< APvmController >, and PsPvmBenchController< PsMultiThreadedPvmController >. Definition at line 121 of file PsSoftRealTimeController.cxx. References PsController::_date, PsBenchController< BenchedController >::_endSamplingDate, PsBenchController< BenchedController >::_numberOfSamples, PsController::_numberOfSimulatedSteps, PsBenchController< BenchedController >::_sampleIndex, PsBenchController< BenchedController >::_slowedDownStepDurationTab, PsBenchController< BenchedController >::_startSamplingDate, PsBenchController< BenchedController >::_stepDurationTab, PsController::_stepPeriod, PsController::compute(), and PsBenchController< BenchedController >::flushResults(). Referenced by PsPvmBenchController< APvmController >::compute().
00121 {
00122 static long avance = 0 ;
00123 //initialisation des compteurs du pas de calcul
00124 if ((_startSamplingDate<=_date)&&(_date<=_endSamplingDate)) {
00125 static timespec avant, apres;
00126 clock_gettime(CLOCK_SGI_CYCLE, &avant);
00127 PsController::compute ();
00128 //lecture des compteurs du pas de calcul
00129 clock_gettime(CLOCK_SGI_CYCLE, &apres);
00130 //remplissage de la table globale
00131 long duree = apres.tv_nsec - avant.tv_nsec ;
00132 if (duree < 0 ) duree = apres.tv_nsec + ( LONG_MAX/2 - avant.tv_nsec ) ;
00133 _stepDurationTab[_sampleIndex] = duree ;
00134 _sampleIndex++;
00135 //Les 4 lignes qui suivent sont une tentative primitive d'atteinte du temps réel
00136 avance += _stepPeriod * 1000 - duree / 1000 ;
00137 if (avance > 10000) {
00138 usleep( avance );
00139 clock_gettime(CLOCK_SGI_CYCLE, &apres);
00140 if (apres.tv_nsec > avant.tv_nsec) {
00141 avance = avance - (apres.tv_nsec - avant.tv_nsec) / 1000 ;
00142 }
00143 else {
00144 avance = avance - (( LONG_MAX/2 - avant.tv_nsec ) + apres.tv_nsec ) / 1000 ;
00145 }
00146 }
00147 _slowedDownStepDurationTab[_numberOfSimulatedSteps%_numberOfSamples] = apres.tv_nsec - avant.tv_nsec ;
00148 if (_slowedDownStepDurationTab[_numberOfSimulatedSteps%_numberOfSamples] < 0) {
00149 _slowedDownStepDurationTab[_numberOfSimulatedSteps%_numberOfSamples] = ( LONG_MAX/2 - avant.tv_nsec ) + apres.tv_nsec ;
00150 }
00151 if (_date==_endSamplingDate) {
00152 flushResults();
00153 _sampleIndex=-1;
00154 }
00155 }
00156 else {
00157 PsController::compute ();
00158 }
00159 }
|
|
|||||||||
|
create a scheduler than can bench stuff
Reimplemented from PsController. Reimplemented in PsMultiThreadedBenchmarkingController, PsMultiThreadedPvmBenchmarkingController, PsPvmBenchController< APvmController >, and PsPvmBenchController< PsMultiThreadedPvmController >. |
|
|||||||||
|
|||||||||
|
writes the sampled results to a file if a filename was given, to stdout otherwise
Definition at line 68 of file PsSoftRealTimeController.cxx. References PsBenchController< BenchedController >::_file, and PsBenchController< BenchedController >::printToStream(). Referenced by PsBenchController< BenchedController >::compute().
00069 {
00070 if(_file == NULL)
00071 {
00072 printToStream(cout);
00073 }
00074 else
00075 {
00076 printToStream(*_file);
00077 }
00078 }
|
|
|||||||||
|
||||||||||
|
write the sampled result to a stream
Definition at line 161 of file PsSoftRealTimeController.cxx. References PsBenchController< BenchedController >::_numberOfSamples, PsBenchController< BenchedController >::_slowedDownStepDurationTab, PsBenchController< BenchedController >::_stepDurationTab, and PsController::_stepPeriod. Referenced by PsBenchController< BenchedController >::flushResults().
00161 {
00162 timespec resolutionHorloge;
00163 long moyenne;
00164 long averageTimeSlowed = 0 ;
00165 int nbValeurs;
00166 long duree;
00167 out<<syssgi(SGI_CYCLECNTR_SIZE) ;
00168 clock_getres(CLOCK_SGI_CYCLE,&resolutionHorloge);
00169 out<<"resolution de l'horloge en secondes : "<<resolutionHorloge.tv_sec<<endl;
00170 out<<"resolution de l'horloge en nanosecondes : "<<resolutionHorloge.tv_nsec<<endl;
00171 moyenne=0;
00172 nbValeurs=0;
00173 for(int i=0;i<_numberOfSamples;i++) {
00174 duree=_stepDurationTab[i];
00175 out<<duree/1000<<" "<<_slowedDownStepDurationTab[i]/1000<<endl;
00176 if (duree>=0) {
00177 moyenne = moyenne+(duree/1000);
00178 averageTimeSlowed = averageTimeSlowed + (_slowedDownStepDurationTab[i]/1000);
00179 nbValeurs++;
00180 }
00181 }
00182 out<<"Soit une moyenne corrigée de : "<<moyenne/nbValeurs<<" microsecondes"<<endl;
00183 out<<"Soit une moyenne ralentie de : "<<averageTimeSlowed/(1000*nbValeurs)<<" millisecondes "<<_stepPeriod<<endl;
00184 }
|
|
|||||
|
the date at wich sampling finishes
Reimplemented from PsTimerController< BenchedController >. Definition at line 76 of file PsSoftRealTimeController.h. Referenced by PsBenchController< BenchedController >::advanceSimulatedDate(), PsBenchController< BenchedController >::compute(), PsBenchController< BenchedController >::createScheduler(), and PsBenchController< BenchedController >::init(). |
|
|||||
|
a pointer to the file to which is written all data collected
Definition at line 82 of file PsSoftRealTimeController.h. |
|
|||||
|
a pointer to the file to which is written all data collected
Definition at line 63 of file PsBenchController.h. Referenced by PsBenchController< BenchedController >::createScheduler(), PsBenchController< BenchedController >::flushResults(), PsBenchController< BenchedController >::PsBenchController(), and PsBenchController< BenchedController >::~PsBenchController(). |
|
|||||
|
the number of samples to take
Reimplemented from PsTimerController< BenchedController >. Definition at line 70 of file PsSoftRealTimeController.h. Referenced by PsBenchController< BenchedController >::compute(), PsBenchController< BenchedController >::createScheduler(), PsBenchController< BenchedController >::init(), and PsBenchController< BenchedController >::printToStream(). |
|
|||||
|
the file name to which the results must be written
Definition at line 61 of file PsSoftRealTimeController.h. Referenced by PsBenchController< BenchedController >::PsBenchController(). |
|
|||||
|
index of the current sample
Definition at line 79 of file PsSoftRealTimeController.h. Referenced by PsBenchController< BenchedController >::advanceSimulatedDate(), PsBenchController< BenchedController >::compute(), PsBenchController< BenchedController >::createScheduler(), and PsBenchController< BenchedController >::init(). |
|
|||||
|
a table recording the time, it took to calculate and wait for each simualtion step
Definition at line 67 of file PsSoftRealTimeController.h. Referenced by PsBenchController< BenchedController >::compute(), PsBenchController< BenchedController >::init(), and PsBenchController< BenchedController >::printToStream(). |
|
|||||
|
the date at wich sampling starts
Reimplemented from PsTimerController< BenchedController >. Definition at line 73 of file PsSoftRealTimeController.h. Referenced by PsBenchController< BenchedController >::advanceSimulatedDate(), PsBenchController< BenchedController >::compute(), PsBenchController< BenchedController >::createScheduler(), and PsBenchController< BenchedController >::init(). |
|
|||||
|
a table recording the time it took to calculated each simulation step
Reimplemented in PsPvmBenchController< APvmController >, and PsPvmBenchController< PsMultiThreadedPvmController >. Definition at line 64 of file PsSoftRealTimeController.h. Referenced by PsBenchController< BenchedController >::compute(), PsBenchController< BenchedController >::init(), and PsBenchController< BenchedController >::printToStream(). |
| Documentation generated on Mon Nov 25 15:25:52 2002 |
Generated with doxygen 1.2.12 by Dimitri van Heesch , 1997-2001 |