blob: ca748d24497530cd269b55c128655c12330bde06 [file] [log] [blame]
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <string>
namespace metrics {
// Struct containing the CPU identity fields used to choose perf commands.
// These are populated from base::CPU, but having them in a settable struct
// makes things testable.
struct CPUIdentity {
CPUIdentity(const CPUIdentity& other);
// The system architecture based on uname().
// (Technically, not a property of the CPU.)
std::string arch;
// The kernel release version.
std::string release;
// CUID fields:
std::string vendor; // e.g. "GenuineIntel"
int family;
int model;
// CPU model name. e.g. "Intel(R) Celeron(R) 2955U @ 1.40GHz"
std::string model_name;
// Get the CPUIdentity based on the actual system.
CPUIdentity GetCPUIdentity();
// Return the CPU microarchitecture based on the family and model derived
// from |cpuid|, and kCpuUarchTable, or the empty string for unknown
// microarchitectures.
std::string GetCpuUarch(const CPUIdentity& cpuid);
// Simplify a CPU model name. The rules are:
// - Replace spaces with hyphens.
// - Strip all "(R)" symbols.
// - Convert to lower case.
std::string SimplifyCPUModelName(const std::string& model_name);
namespace internal {
// Exposed for unit testing.
struct CpuUarchTableEntry {
const char *family_model;
const char *uarch;
bool CpuUarchTableCmp(const CpuUarchTableEntry& a, const CpuUarchTableEntry& b);
extern const CpuUarchTableEntry kCpuUarchTable[];
extern const CpuUarchTableEntry* kCpuUarchTableEnd;
} // namespace internal
} // namespace metrics