mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
Implement a uniform way to query processor core IDs
This commit is contained in:
parent
e96b25508e
commit
f76f989b53
@ -1041,18 +1041,16 @@ void AsynchronousMetrics::update(TimePoint update_time)
|
||||
// It doesn't read the EOL itself.
|
||||
++cpuinfo->position();
|
||||
|
||||
if (s.rfind("processor", 0) == 0)
|
||||
static constexpr std::string_view PROCESSOR = "processor";
|
||||
if (s.starts_with(PROCESSOR))
|
||||
{
|
||||
/// s390x example: processor 0: version = FF, identification = 039C88, machine = 3906
|
||||
/// non s390x example: processor : 0
|
||||
if (auto colon = s.find_first_of(':'))
|
||||
{
|
||||
#ifdef __s390x__
|
||||
core_id = std::stoi(s.substr(10)); /// 10: length of "processor" plus 1
|
||||
#else
|
||||
core_id = std::stoi(s.substr(colon + 2));
|
||||
#endif
|
||||
}
|
||||
auto core_id_start = std::ssize(PROCESSOR);
|
||||
while (core_id_start < std::ssize(s) && !std::isdigit(s[core_id_start]))
|
||||
++core_id_start;
|
||||
|
||||
core_id = std::stoi(s.substr(core_id_start));
|
||||
}
|
||||
else if (s.rfind("cpu MHz", 0) == 0)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user