#include <CPU.h>
Public Member Functions | |
CPU (ParameterSet const &, ActivityRegistry &) | |
~CPU () | |
Static Public Member Functions | |
static void | fillDescriptions (ConfigurationDescriptions &descriptions) |
Private Member Functions | |
void | postEndJob () |
Private Attributes | |
double | averageCoreSpeed_ |
bool | reportCPUProperties_ |
int | totalNumberCPUs_ |
edm::service::CPU::CPU | ( | ParameterSet const & | iPS, |
ActivityRegistry & | iRegistry | ||
) |
Definition at line 82 of file CPU.cc.
References postEndJob(), and edm::ActivityRegistry::watchPostEndJob().
: totalNumberCPUs_(0), averageCoreSpeed_(0.0), reportCPUProperties_(iPS.getUntrackedParameter<bool>("reportCPUProperties")) { iRegistry.watchPostEndJob(this,&CPU::postEndJob); }
void edm::service::CPU::fillDescriptions | ( | edm::ConfigurationDescriptions & | descriptions | ) | [static] |
Definition at line 95 of file CPU.cc.
References edm::ConfigurationDescriptions::add(), and edm::ParameterSetDescription::addUntracked().
{ edm::ParameterSetDescription desc; desc.addUntracked<bool>("reportCPUProperties", false); descriptions.add("CPU", desc); }
void edm::service::CPU::postEndJob | ( | ) | [private] |
Definition at line 102 of file CPU.cc.
References averageCoreSpeed_, edm::service::d2str(), edm::service::i2str(), reportCPUProperties_, cond::rpcobgas::time, totalNumberCPUs_, and relativeConstraints::value.
Referenced by CPU().
{ Service<JobReport> reportSvc; std::map<std::string, std::string> reportCPUProperties; // Summary std::map<std::string, std::string> currentCoreProperties; // Module(s) std::ifstream fcpuinfo ("/proc/cpuinfo"); if(fcpuinfo.is_open()){ std::string buf; std::string currentCore; std::string CPUModels; std::set<std::string> models; while(!fcpuinfo.eof()){ std::getline(fcpuinfo, buf); std::istringstream iss(buf); std::string token; std::string property; std::string value; int time = 1; while(std::getline(iss, token, ':')) { switch(time){ case 1: property = token; break; case 2: value = token; break; default: value += token; break; } time++; } trim(property); trim(value); if(!property.empty()){ if(property == "processor") { if(reportCPUProperties_){ if(currentCore.empty()) { // first core currentCore = value; } else{ reportSvc->reportPerformanceForModule("SystemCPU", "CPU-"+currentCore, currentCoreProperties); currentCoreProperties.clear(); currentCore = value; } } totalNumberCPUs_++; } else { if(reportCPUProperties_){ currentCoreProperties.insert(std::make_pair(property, value)); } if(property == "cpu MHz"){ averageCoreSpeed_ += str2d(value); } if(property == "model name"){ models.insert(eraseExtraSpaces(value)); } } } } //while fcpuinfo.close(); if(!currentCore.empty() && reportCPUProperties_) { reportSvc->reportPerformanceForModule("SystemCPU", "CPU-"+currentCore, currentCoreProperties); } reportCPUProperties.insert(std::make_pair("totalCPUs", i2str(totalNumberCPUs_))); if(totalNumberCPUs_ == 0){ averageCoreSpeed_ = 0.0; } else{ averageCoreSpeed_ = averageCoreSpeed_/totalNumberCPUs_; } reportCPUProperties.insert(std::make_pair("averageCoreSpeed", d2str(averageCoreSpeed_))); int model = 0; for(std::set<std::string>::const_iterator iter = models.begin(); iter != models.end(); iter++){ if(model == 0) CPUModels += *iter; else CPUModels += ", " + *iter; model++; } reportCPUProperties.insert(std::make_pair("CPUModels", CPUModels)); reportSvc->reportPerformanceSummary("SystemCPU", reportCPUProperties); } //if } //postEndJob
double edm::service::CPU::averageCoreSpeed_ [private] |
Definition at line 33 of file CPU.h.
Referenced by postEndJob().
bool edm::service::CPU::reportCPUProperties_ [private] |
Definition at line 34 of file CPU.h.
Referenced by postEndJob().
int edm::service::CPU::totalNumberCPUs_ [private] |
Definition at line 32 of file CPU.h.
Referenced by postEndJob().