00001 #ifndef EVF_CPUSTAT 00002 #define EVF_CPUSTAT 00003 00004 #include <vector> 00005 #include <string> 00006 #include <iostream> 00007 00008 namespace evf{ 00009 00010 class CurlPoster; 00011 00012 class CPUStat{ 00013 public: 00014 CPUStat(unsigned int nstates, std::string iDieUrl); 00015 ~CPUStat(); 00016 void addEntry(int sta) 00017 { 00018 mstat_[sta]++; 00019 entries_++; 00020 } 00021 void reset() 00022 { 00023 for(int i = 0; i < nstates_; i++) 00024 mstat_[i]=0; 00025 entries_ = 0; 00026 } 00027 void printStat(){ 00028 std::cout << "dump of microstates avg.:" << entries_ << " samples" << std::endl; 00029 for(int i = 0; i < nstates_; i++) 00030 if(mstat_[i]!=0) std::cout << i << " " << float(mstat_[i])/float(entries_) 00031 << std::endl; 00032 } 00033 void sendStat(unsigned int); 00034 void sendLegenda(const std::vector<std::string> &); 00035 private: 00036 std::string iDieUrl_; 00037 CurlPoster *poster_; 00038 int nstates_; 00039 int entries_; 00040 int *mstat_; 00041 }; 00042 } 00043 #endif