summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/cpu.cc12
-rw-r--r--base/cpu.h15
-rw-r--r--chrome/browser/chrome_browser_main.cc12
3 files changed, 39 insertions, 0 deletions
diff --git a/base/cpu.cc b/base/cpu.cc
index cf4f2f1..d6976ba 100644
--- a/base/cpu.cc
+++ b/base/cpu.cc
@@ -117,6 +117,7 @@ void CPU::Initialize() {
has_ssse3_ = (cpu_info[2] & 0x00000200) != 0;
has_sse41_ = (cpu_info[2] & 0x00080000) != 0;
has_sse42_ = (cpu_info[2] & 0x00100000) != 0;
+ has_avx_ = (cpu_info[2] & 0x10000000) != 0;
}
// Get the brand string of the cpu.
@@ -137,4 +138,15 @@ void CPU::Initialize() {
#endif
}
+CPU::IntelMicroArchitecture CPU::GetIntelMicroArchitecture() const {
+ if (has_avx()) return AVX;
+ if (has_sse42()) return SSE42;
+ if (has_sse41()) return SSE41;
+ if (has_ssse3()) return SSSE3;
+ if (has_sse3()) return SSE3;
+ if (has_sse2()) return SSE2;
+ if (has_sse()) return SSE;
+ return PENTIUM;
+}
+
} // namespace base
diff --git a/base/cpu.h b/base/cpu.h
index 957b1a5..65fda47 100644
--- a/base/cpu.h
+++ b/base/cpu.h
@@ -17,6 +17,18 @@ class BASE_EXPORT CPU {
// Constructor
CPU();
+ enum IntelMicroArchitecture {
+ PENTIUM,
+ SSE,
+ SSE2,
+ SSE3,
+ SSSE3,
+ SSE41,
+ SSE42,
+ AVX,
+ MAX_INTEL_MICRO_ARCHITECTURE
+ };
+
// Accessors for CPU information.
const std::string& vendor_name() const { return cpu_vendor_; }
int stepping() const { return stepping_; }
@@ -32,6 +44,8 @@ class BASE_EXPORT CPU {
bool has_ssse3() const { return has_ssse3_; }
bool has_sse41() const { return has_sse41_; }
bool has_sse42() const { return has_sse42_; }
+ bool has_avx() const { return has_avx_; }
+ IntelMicroArchitecture GetIntelMicroArchitecture() const;
const std::string& cpu_brand() const { return cpu_brand_; }
private:
@@ -51,6 +65,7 @@ class BASE_EXPORT CPU {
bool has_ssse3_;
bool has_sse41_;
bool has_sse42_;
+ bool has_avx_;
std::string cpu_vendor_;
std::string cpu_brand_;
};
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc
index 245f860..8083563 100644
--- a/chrome/browser/chrome_browser_main.cc
+++ b/chrome/browser/chrome_browser_main.cc
@@ -14,6 +14,7 @@
#include "base/at_exit.h"
#include "base/bind.h"
#include "base/command_line.h"
+#include "base/cpu.h"
#include "base/debug/trace_event.h"
#include "base/file_path.h"
#include "base/file_util.h"
@@ -207,6 +208,13 @@ using content::BrowserThread;
namespace {
+void LogIntelMicroArchitecture() {
+ base::CPU cpu;
+ base::CPU::IntelMicroArchitecture arch = cpu.GetIntelMicroArchitecture();
+ UMA_HISTOGRAM_ENUMERATION("Platform.IntelMaxMicroArchitecture", arch,
+ base::CPU::MAX_INTEL_MICRO_ARCHITECTURE);
+}
+
// This function provides some ways to test crash and assertion handling
// behavior of the program.
void HandleTestParameters(const CommandLine& command_line) {
@@ -1029,6 +1037,10 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
StartMetricsRecording();
#endif
+#if defined(ARCH_CPU_X86_FAMILY)
+ LogIntelMicroArchitecture();
+#endif // defined(ARCH_CPU_X86_FAMILY)
+
// Create watchdog thread after creating all other threads because it will
// watch the other threads and they must be running.
browser_process_->watchdog_thread();