CMS 3D CMS Logo

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