22 #include <sys/resource.h>
46 return atof(s.c_str());
50 return atoi(s.c_str());
55 if(p != std::string::npos) {
58 s = s.erase(0, s.find_first_not_of(
drop));
64 for(std::string::const_iterator iter = s.begin(); iter != s.end(); iter++){
66 if(*iter ==
' ') founded =
true;
68 aux +=
" "; aux += *iter;
73 if(*iter ==
' ') founded =
true;
84 averageCoreSpeed_(0.0),
85 reportCPUProperties_(iPS.getUntrackedParameter<bool>(
"reportCPUProperties"))
98 descriptions.
add(
"CPU", desc);
106 std::map<std::string, std::string> reportCPUProperties;
107 std::map<std::string, std::string> currentCoreProperties;
109 std::ifstream fcpuinfo (
"/proc/cpuinfo");
111 if(fcpuinfo.is_open()){
117 std::set<std::string> models;
119 while(!fcpuinfo.eof()){
121 std::getline(fcpuinfo, buf);
123 std::istringstream iss(buf);
130 while(std::getline(iss, token,
':')) {
147 if(!property.empty()){
148 if(property ==
"processor") {
150 if(currentCore.empty()) {
154 reportSvc->reportPerformanceForModule(
"SystemCPU",
"CPU-"+currentCore, currentCoreProperties);
155 currentCoreProperties.clear();
163 currentCoreProperties.insert(std::make_pair(property, value));
165 if(property ==
"cpu MHz"){
168 if(property ==
"model name"){
169 models.insert(eraseExtraSpaces(value));
178 reportSvc->reportPerformanceForModule(
"SystemCPU",
"CPU-"+currentCore, currentCoreProperties);
193 for(std::set<std::string>::const_iterator iter = models.begin(); iter != models.end(); iter++){
197 CPUModels +=
", " + *iter;
200 reportCPUProperties.insert(std::make_pair(
"CPUModels", CPUModels));
203 reportSvc->reportPerformanceSummary(
"SystemCPU", reportCPUProperties);
static std::string i2str(int i)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void watchPostEndJob(PostEndJob::slot_type const &iSlot)
bool reportCPUProperties_
CPU(ParameterSet const &, ActivityRegistry &)
static std::string d2str(double d)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(ConfigurationDescriptions &descriptions)