CMS 3D CMS Logo

processor_model.cc
Go to the documentation of this file.
1 #include <fstream>
2 #include <regex>
3 #include <string>
4 
5 #include "processor_model.h"
6 
8 {
9 #ifdef __linux__
10  static const std::regex pattern("^model name\\s*:\\s*(.*)", std::regex::optimize);
11  std::smatch match;
12 
13  std::ifstream cpuinfo("/proc/cpuinfo", std::ios::in);
15  while (cpuinfo.good()) {
16  std::getline(cpuinfo, line);
17  if (std::regex_match(line, match, pattern)) {
18  return match[1];
19  }
20  }
21 #endif // __linux__
22 
23  return "unknown";
24 }
25 
std::string read_processor_model()
const std::string processor_model
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10