HLTrigger
Timer
src
processor_model.cc
Go to the documentation of this file.
1
#include <string>
2
#include <boost/predef/os.h>
3
4
#if BOOST_OS_LINUX
5
// Linux
6
#include <fstream>
7
#include <regex>
8
#endif // BOOST_OS_LINUX
9
10
#if BOOST_OS_BSD || BOOST_OS_MACOS
11
// OSX or BSD
12
#include <sys/types.h>
13
#include <sys/sysctl.h>
14
#endif // BOOST_OS_BSD || BOOST_OS_MACOS
15
16
#include "
HLTrigger/Timer/interface/processor_model.h
"
17
18
std::string
read_processor_model
() {
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
);
25
std::string
line
;
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", ...)
36
std::string
result
;
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
}
46
47
const
std::string
processor_model
=
read_processor_model
();
processor_model
const std::string processor_model
Definition:
processor_model.cc:47
processor_model.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
read_processor_model
std::string read_processor_model()
Definition:
processor_model.cc:18
recoMuon::in
Definition:
RecoMuonEnumerators.h:6
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition:
Utils.h:10
topSingleLeptonDQM_PU_cfi.pattern
pattern
Definition:
topSingleLeptonDQM_PU_cfi.py:39
NULL
#define NULL
Definition:
scimark2.h:8
mps_fire.result
result
Definition:
mps_fire.py:303
mps_splice.line
line
Definition:
mps_splice.py:76
Generated for CMSSW Reference Manual by
1.8.16