CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions | Variables
processor_model.cc File Reference
#include <string>
#include <boost/predef/os.h>
#include "HLTrigger/Timer/interface/processor_model.h"

Go to the source code of this file.

Functions

std::string read_processor_model ()
 

Variables

const std::string processor_model = read_processor_model()
 

Function Documentation

std::string read_processor_model ( )

Definition at line 18 of file processor_model.cc.

References recoMuon::in, geometryCSVtoXML::line, match(), NULL, mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

18  {
19 #if BOOST_OS_LINUX
20  // on Linux, read the processor model from /proc/cpuinfo
21  static const std::regex pattern("^model name\\s*:\\s*(.*)", std::regex::optimize);
22  std::smatch match;
23 
24  std::ifstream cpuinfo("/proc/cpuinfo", std::ios::in);
26  while (cpuinfo.good()) {
27  std::getline(cpuinfo, line);
28  if (std::regex_match(line, match, pattern)) {
29  return match[1];
30  }
31  }
32 #endif // BOOST_OS_LINUX
33 
34 #if BOOST_OS_BSD || BOOST_OS_MACOS
35  // on BSD and OS X, read the processor model via sysctlbyname("machdep.cpu.brand_string", ...)
37  size_t len;
38  sysctlbyname("machdep.cpu.brand_string", nullptr, &len, NULL, 0);
39  result.resize(len);
40  sysctlbyname("machdep.cpu.brand_string", result.data(), &len, NULL, 0);
41  return result;
42 #endif // BOOST_OS_BSD || BOOST_OS_MACOS
43 
44  return "unknown";
45 }
#define NULL
Definition: scimark2.h:8
tuple result
Definition: mps_fire.py:311
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10

Variable Documentation

const std::string processor_model = read_processor_model()