• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright 2008 The WebRTC Project Authors. All rights reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef WEBRTC_BASE_SYSTEMINFO_H__
12 #define WEBRTC_BASE_SYSTEMINFO_H__
13 
14 #include <string>
15 
16 #include "webrtc/base/basictypes.h"
17 
18 namespace rtc {
19 
20 class SystemInfo {
21  public:
22   enum Architecture {
23     SI_ARCH_UNKNOWN = -1,
24     SI_ARCH_X86 = 0,
25     SI_ARCH_X64 = 1,
26     SI_ARCH_ARM = 2
27   };
28 
29   SystemInfo();
30 
31   // The number of CPU Cores in the system.
32   int GetMaxPhysicalCpus();
33   // The number of CPU Threads in the system.
34   int GetMaxCpus();
35   // The number of CPU Threads currently available to this process.
36   int GetCurCpus();
37   // Identity of the CPUs.
38   Architecture GetCpuArchitecture();
39   std::string GetCpuVendor();
40   int GetCpuFamily();
41   int GetCpuModel();
42   int GetCpuStepping();
43   // Return size of CPU cache in bytes.  Uses largest available cache (L3).
44   int GetCpuCacheSize();
45   // Estimated speed of the CPUs, in MHz.  e.g. 2400 for 2.4 GHz
46   int GetMaxCpuSpeed();
47   int GetCurCpuSpeed();
48   // Total amount of physical memory, in bytes.
49   int64 GetMemorySize();
50   // The model name of the machine, e.g. "MacBookAir1,1"
51   std::string GetMachineModel();
52 
53   // The gpu identifier
54   struct GpuInfo {
GpuInfoGpuInfo55     GpuInfo() : vendor_id(0), device_id(0) {}
56     std::string device_name;
57     std::string description;
58     int vendor_id;
59     int device_id;
60     std::string driver;
61     std::string driver_version;
62   };
63   bool GetGpuInfo(GpuInfo *info);
64 
65  private:
66   int physical_cpus_;
67   int logical_cpus_;
68   int cache_size_;
69   Architecture cpu_arch_;
70   std::string cpu_vendor_;
71   int cpu_family_;
72   int cpu_model_;
73   int cpu_stepping_;
74   int cpu_speed_;
75   int64 memory_;
76   std::string machine_model_;
77 };
78 
79 }  // namespace rtc
80 
81 #endif  // WEBRTC_BASE_SYSTEMINFO_H__
82