OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/metrics/perf/cpu_identity.h" | 5 #include "chrome/browser/metrics/perf/cpu_identity.h" |
6 | 6 |
7 #include <algorithm> // for std::lower_bound() | 7 #include <algorithm> // for std::lower_bound() |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include "base/cpu.h" | 10 #include "base/cpu.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 70 |
71 CPUIdentity::~CPUIdentity() {} | 71 CPUIdentity::~CPUIdentity() {} |
72 | 72 |
73 std::string GetIntelUarch(const CPUIdentity& cpuid) { | 73 std::string GetIntelUarch(const CPUIdentity& cpuid) { |
74 if (cpuid.vendor != "GenuineIntel") | 74 if (cpuid.vendor != "GenuineIntel") |
75 return std::string(); // Non-Intel | 75 return std::string(); // Non-Intel |
76 | 76 |
77 std::string family_model = | 77 std::string family_model = |
78 base::StringPrintf("%02X_%02X", cpuid.family, cpuid.model); | 78 base::StringPrintf("%02X_%02X", cpuid.family, cpuid.model); |
79 const internal::IntelUarchTableEntry search_elem = {family_model.c_str(), ""}; | 79 const internal::IntelUarchTableEntry search_elem = {family_model.c_str(), ""}; |
80 const auto bound = std::lower_bound( | 80 auto* bound = std::lower_bound(internal::kIntelUarchTable, |
81 internal::kIntelUarchTable, internal::kIntelUarchTableEnd, | 81 internal::kIntelUarchTableEnd, search_elem, |
82 search_elem, internal::IntelUarchTableCmp); | 82 internal::IntelUarchTableCmp); |
83 if (bound->family_model != family_model) | 83 if (bound->family_model != family_model) |
84 return std::string(); // Unknown uarch | 84 return std::string(); // Unknown uarch |
85 return bound->uarch; | 85 return bound->uarch; |
86 } | 86 } |
87 | 87 |
88 CPUIdentity GetCPUIdentity() { | 88 CPUIdentity GetCPUIdentity() { |
89 CPUIdentity result = {}; | 89 CPUIdentity result = {}; |
90 result.arch = base::SysInfo::OperatingSystemArchitecture(); | 90 result.arch = base::SysInfo::OperatingSystemArchitecture(); |
91 base::CPU cpuid; | 91 base::CPU cpuid; |
92 result.vendor = cpuid.vendor_name(); | 92 result.vendor = cpuid.vendor_name(); |
93 result.family = cpuid.family(); | 93 result.family = cpuid.family(); |
94 result.model = cpuid.model(); | 94 result.model = cpuid.model(); |
95 result.model_name = cpuid.cpu_brand(); | 95 result.model_name = cpuid.cpu_brand(); |
96 return result; | 96 return result; |
97 } | 97 } |
98 | 98 |
99 std::string SimplifyCPUModelName(const std::string& model_name) { | 99 std::string SimplifyCPUModelName(const std::string& model_name) { |
100 std::string result = model_name; | 100 std::string result = model_name; |
101 std::replace(result.begin(), result.end(), ' ', '-'); | 101 std::replace(result.begin(), result.end(), ' ', '-'); |
102 base::ReplaceSubstringsAfterOffset(&result, 0, "(R)", ""); | 102 base::ReplaceSubstringsAfterOffset(&result, 0, "(R)", ""); |
103 return base::ToLowerASCII(result); | 103 return base::ToLowerASCII(result); |
104 } | 104 } |
105 | 105 |
OLD | NEW |