23 #include <sys/resource.h>
72 return atof(s.c_str());
76 return atoi(s.c_str());
81 if(p != std::string::npos) {
84 s = s.erase(0, s.find_first_not_of(
drop));
90 for(std::string::const_iterator iter = s.begin(); iter != s.end(); iter++){
92 if(*iter ==
' ') founded =
true;
94 aux +=
" "; aux += *iter;
99 if(*iter ==
' ') founded =
true;
110 averageCoreSpeed_(0.0),
111 reportCPUProperties_(iPS.getUntrackedParameter<bool>(
"reportCPUProperties"))
124 descriptions.
add(
"CPU", desc);
132 std::map<std::string, std::string> reportCPUProperties;
133 std::map<std::string, std::string> currentCoreProperties;
135 std::ifstream fcpuinfo (
"/proc/cpuinfo");
137 if(fcpuinfo.is_open()){
143 std::set<std::string> models;
145 while(!fcpuinfo.eof()){
147 std::getline(fcpuinfo, buf);
149 std::istringstream iss(buf);
156 while(std::getline(iss, token,
':')) {
173 if(!property.empty()){
174 if(property ==
"processor") {
176 if(currentCore.empty()) {
180 reportSvc->reportPerformanceForModule(
"SystemCPU",
"CPU-"+currentCore, currentCoreProperties);
181 currentCoreProperties.clear();
189 currentCoreProperties.insert(std::make_pair(property, value));
191 if(property ==
"cpu MHz"){
194 if(property ==
"model name"){
195 models.insert(eraseExtraSpaces(value));
204 reportSvc->reportPerformanceForModule(
"SystemCPU",
"CPU-"+currentCore, currentCoreProperties);
219 for(std::set<std::string>::const_iterator iter = models.begin(); iter != models.end(); iter++){
223 CPUModels +=
", " + *iter;
226 reportCPUProperties.insert(std::make_pair(
"CPUModels", CPUModels));
229 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_
bool isProcessWideService(TFileService const *)
#define DEFINE_FWK_SERVICE(type)
CPU(ParameterSet const &, ActivityRegistry &)
static std::string d2str(double d)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(ConfigurationDescriptions &descriptions)