CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/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 reset()
00029     {
00030       for(int i = 0; i < nstates_; i++)
00031         mstat_[i]=0;    
00032       entries_ = 0;
00033     }
00034     void printStat(){
00035       std::cout << "dump of microstates avg.:" << entries_ << " samples" << std::endl;
00036       for(int i = 0; i < nstates_; i++)
00037         if(mstat_[i]!=0) std::cout << i << " " << float(mstat_[i])/float(entries_)
00038                                    << std::endl;
00039     }
00040     std::string &getChart(){return chart_.draw();}
00041     void sendStat(unsigned int);
00042     void sendLegenda(const std::vector<std::string> &);
00043   private:
00044     std::string iDieUrl_;
00045     CurlPoster *poster_;
00046     int nstates_;
00047     int nproc_;
00048     int instance_;
00049     int entries_;
00050     int *mstat_;
00051     AsciiRollingChart chart_;
00052   };
00053 }
00054 #endif