CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/EventFilter/Utilities/interface/CPUStat.h

Go to the documentation of this file.
00001 #ifndef EVF_CPUSTAT
00002 #define EVF_CPUSTAT
00003 
00004 #include <vector>
00005 #include <string>
00006 #include <iostream>
00007 #include "EventFilter/Utilities/interface/AsciiRollingChart.h"
00008 
00009 namespace evf{
00010 
00011   class CurlPoster;
00012 
00013   class CPUStat{
00014   public:
00015     CPUStat(unsigned int nstates, unsigned int nproc, unsigned int instance, std::string iDieUrl);
00016     ~CPUStat();
00017     void addEntry(int sta)
00018     {
00019       mstat_[sta]++;
00020       entries_++;
00021     }
00022     void setNproc(int nproc){
00023       mstat_[nstates_+2]=nproc;
00024     }
00025     void setCPUStat(int busyPer1k) {
00026       mstat_[nstates_+3]=busyPer1k;
00027     }
00028     void setElapsed(int mseconds) {
00029       mstat_[nstates_+4]=mseconds;
00030     }
00031     void reset()
00032     {
00033       for(int i = 0; i < nstates_; i++)
00034         mstat_[i]=0;    
00035       entries_ = 0;
00036     }
00037     void printStat(){
00038       std::cout << "dump of microstates avg.:" << entries_ << " samples" << std::endl;
00039       for(int i = 0; i < nstates_; i++)
00040         if(mstat_[i]!=0) std::cout << i << " " << float(mstat_[i])/float(entries_)
00041                                    << std::endl;
00042     }
00043     std::string &getChart(){return chart_.draw();}
00044     void sendStat(unsigned int);
00045     void sendLegenda(const std::vector<std::string> &);
00046   private:
00047     std::string iDieUrl_;
00048     CurlPoster *poster_;
00049     int nstates_;
00050     int nproc_;
00051     int instance_;
00052     int entries_;
00053     int *mstat_;
00054     AsciiRollingChart chart_;
00055   };
00056 }
00057 #endif