Skip to content

Commit

Permalink
Include CPU information in UMA system profile.
Browse files Browse the repository at this point in the history
This is particularly useful to help determine which CPUs fail to tick
monotonically in HighResNow() on Windows.

BUG=254211

Review URL: https://chromiumcodereview.appspot.com/17770005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212323 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
simonjam@chromium.org committed Jul 18, 2013
1 parent 31d4df8 commit 5c8f89f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
4 changes: 3 additions & 1 deletion base/cpu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
namespace base {

CPU::CPU()
: type_(0),
: signature_(0),
type_(0),
family_(0),
model_(0),
stepping_(0),
Expand Down Expand Up @@ -105,6 +106,7 @@ void CPU::Initialize() {
// Interpret CPU feature information.
if (num_ids > 0) {
__cpuid(cpu_info, 1);
signature_ = cpu_info[0];
stepping_ = cpu_info[0] & 0xf;
model_ = ((cpu_info[0] >> 4) & 0xf) + ((cpu_info[0] >> 12) & 0xf0);
family_ = (cpu_info[0] >> 8) & 0xf;
Expand Down
2 changes: 2 additions & 0 deletions base/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class BASE_EXPORT CPU {

// Accessors for CPU information.
const std::string& vendor_name() const { return cpu_vendor_; }
int signature() const { return signature_; }
int stepping() const { return stepping_; }
int model() const { return model_; }
int family() const { return family_; }
Expand All @@ -55,6 +56,7 @@ class BASE_EXPORT CPU {
// Query the processor for CPUID information.
void Initialize();

int signature_; // raw form of type, family, model, and stepping
int type_; // process type
int family_; // family of the processor
int model_; // model of processor
Expand Down
6 changes: 6 additions & 0 deletions chrome/browser/metrics/metrics_log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "base/basictypes.h"
#include "base/bind.h"
#include "base/cpu.h"
#include "base/lazy_instance.h"
#include "base/memory/scoped_ptr.h"
#include "base/perftimer.h"
Expand Down Expand Up @@ -722,6 +723,11 @@ void MetricsLog::RecordEnvironmentProto(
base::android::BuildInfo::GetInstance()->android_build_fp());
#endif

base::CPU cpu_info;
SystemProfileProto::Hardware::CPU* cpu = hardware->mutable_cpu();
cpu->set_vendor_name(cpu_info.vendor_name());
cpu->set_signature(cpu_info.signature());

const gpu::GPUInfo& gpu_info =
GpuDataManager::GetInstance()->GetGPUInfo();
SystemProfileProto::Hardware::Graphics* gpu = hardware->mutable_gpu();
Expand Down
4 changes: 4 additions & 0 deletions chrome/browser/metrics/metrics_log_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ class MetricsLogTest : public testing::Test {
EXPECT_EQ(kScreenScaleFactor, hardware.primary_screen_scale_factor());
EXPECT_EQ(kScreenCount, hardware.screen_count());

EXPECT_TRUE(hardware.has_cpu());
EXPECT_TRUE(hardware.cpu().has_vendor_name());
EXPECT_TRUE(hardware.cpu().has_signature());

// TODO(isherman): Verify other data written into the protobuf as a result
// of this call.
}
Expand Down
12 changes: 11 additions & 1 deletion chrome/common/metrics/proto/system_profile.proto
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ message SystemProfileProto {
}
optional OS os = 5;

// Next tag for Hardware: 13
// Next tag for Hardware: 14
// Information on the user's hardware.
message Hardware {
// The CPU architecture (x86, PowerPC, x86_64, ...)
Expand Down Expand Up @@ -121,6 +121,16 @@ message SystemProfileProto {
optional float max_dpi_x = 9;
optional float max_dpi_y = 10;

// Information on the CPU obtained by CPUID.
message CPU {
// A 12 character string naming the vendor, e.g. "GeniuneIntel".
optional string vendor_name = 1;

// The signature reported by CPUID (from EAX).
optional uint32 signature = 2;
}
optional CPU cpu = 13;

// Information on the GPU
message Graphics {
// The GPU manufacturer's vendor id.
Expand Down

0 comments on commit 5c8f89f

Please sign in to comment.