- Timestamp:
- Oct 11, 2001, 10:15:50 PM (24 years ago)
- Location:
- trunk/ArchTOIPipe/Kernel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ArchTOIPipe/Kernel/toimanager.cc
r1653 r1684 1 1 #include "toimanager.h" 2 #include <unistd.h>3 2 #include <limits.h> 4 3 #include <pthread.h> 5 4 #include <iostream.h> 6 5 6 #ifndef MAXINT 7 #define MAXINT 2147483647 8 #endif 9 7 10 TOIManager::TOIManager() { 8 11 reqBegin = 0; 9 reqEnd = LONG_MAX;12 reqEnd = MAXINT; 10 13 } 11 14 … … 17 20 } 18 21 19 void TOIManager::setRequestedSample( long begin, longend) {22 void TOIManager::setRequestedSample(int begin, int end) { 20 23 reqBegin = begin; 21 24 reqEnd = end; 22 25 } 23 26 24 longTOIManager::getRequestedBegin() {27 int TOIManager::getRequestedBegin() { 25 28 return reqBegin; 26 29 } 27 30 28 longTOIManager::getRequestedEnd() {31 int TOIManager::getRequestedEnd() { 29 32 return reqEnd; 30 33 } … … 44 47 } 45 48 } 46 47 48 // -----------------------------------------------------------------49 // Classe pour affichage de l'avancement des TOIProcessors50 // Reza 08/200151 // -----------------------------------------------------------------52 53 RzProcSampleCounter::RzProcSampleCounter()54 {55 _msg = "SampleCounter/Info";56 _rate = 50;57 }58 59 RzProcSampleCounter::~RzProcSampleCounter()60 {61 }62 63 long RzProcSampleCounter::PrintStats()64 {65 int istart = 0;66 int iend = 0;67 long dns_print = 1000;68 int dns_print_fac = _rate;69 int nbmax_dns_print = 2;70 71 TOIManager* mgr = TOIManager::getManager();72 73 istart = mgr->getRequestedBegin();74 iend = mgr->getRequestedEnd();75 76 dns_print = (iend-istart)/dns_print_fac;77 if (dns_print < 1000) dns_print = ((iend-istart) < 1000) ? (iend-istart) : 1000;78 if (dns_print < 1) dns_print = 1;79 nbmax_dns_print = (iend-istart)/dns_print;80 81 cout << "RzProcSampleCounter::PrintStats() InfoMessage=" << _msg82 << "\n ... " << _msg << " istart="83 << istart << " iend= " << iend << " dns_print= " << dns_print84 << " nbmax_dns_print= " << nbmax_dns_print << endl;85 // ------------------- Impression continu de stat ------------------------86 long nb_dns_print = 0;87 int nb_sleep = 0;88 long last_sample_count = 0;89 long processed_samples = 0;90 long total_sample_count = dns_print*nbmax_dns_print;91 bool alldone = false;92 while (!alldone) {93 processed_samples = ProcessedSampleCount();94 if ( (processed_samples-last_sample_count > dns_print) ||95 (processed_samples > total_sample_count-10) ) {96 last_sample_count = processed_samples;97 if (nb_dns_print == 0) cout << "\n";98 nb_dns_print++;99 cout << ">>> " << _msg << ": ProcessedSampleCount()= " << last_sample_count100 << " Frac done = " << processed_samples*100/total_sample_count << " %" << endl;101 if (last_sample_count > total_sample_count-10) alldone = true;102 nb_sleep = 0;103 }104 else if ((nb_sleep+1)%5 == 0)105 cout << "> " << _msg << ": ProcSamples()= " << processed_samples106 << " Done = " << " %" << processed_samples*100/total_sample_count107 << " NbSleep(1) = " << nb_sleep << endl;108 109 sleep(1); nb_sleep++;110 }111 112 // -----------------------------------------------------------------------113 114 return last_sample_count;115 116 } -
trunk/ArchTOIPipe/Kernel/toimanager.h
r1653 r1684 4 4 #define TOIMANAGER_H 5 5 6 #include <string>7 6 #include <vector> 8 7 … … 12 11 public: 13 12 static TOIManager* getManager(); 14 void setRequestedSample( long begin, longend);15 longgetRequestedBegin();16 longgetRequestedEnd();13 void setRequestedSample(int begin, int end); 14 int getRequestedBegin(); 15 int getRequestedEnd(); 17 16 void addThread(pthread_t*); 18 17 void joinAll(); … … 27 26 }; 28 27 29 30 // -----------------------------------------------------------------31 // Classe pour affichage de l'avancement des TOIProcessors32 // Reza 08/200133 // -----------------------------------------------------------------34 35 class RzProcSampleCounter {36 public:37 RzProcSampleCounter();38 virtual ~RzProcSampleCounter();39 virtual long ProcessedSampleCount() = 0;40 virtual long PrintStats();41 inline int & PrintRate(int pr) { return _rate; }42 inline string& InfoMessage() { return _msg; }43 protected:44 int _rate;45 string _msg;46 };47 48 template <class T>49 class ProcSampleCounter : public RzProcSampleCounter {50 public:51 ProcSampleCounter(const T & t) { _t = &t; }52 virtual long ProcessedSampleCount()53 { return _t->ProcessedSampleCount(); }54 protected:55 const T * _t;56 };57 58 28 #endif
Note:
See TracChangeset
for help on using the changeset viewer.