Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: base/cpu.cc

Issue 17770005: Include CPU information in UMA system profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/cpu.h ('k') | chrome/browser/metrics/metrics_log.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/cpu.h" 5 #include "base/cpu.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 12
13 #if defined(ARCH_CPU_X86_FAMILY) 13 #if defined(ARCH_CPU_X86_FAMILY)
14 #if defined(_MSC_VER) 14 #if defined(_MSC_VER)
15 #include <intrin.h> 15 #include <intrin.h>
16 #endif 16 #endif
17 #endif 17 #endif
18 18
19 namespace base { 19 namespace base {
20 20
21 CPU::CPU() 21 CPU::CPU()
22 : type_(0), 22 : signature_(0),
23 type_(0),
23 family_(0), 24 family_(0),
24 model_(0), 25 model_(0),
25 stepping_(0), 26 stepping_(0),
26 ext_model_(0), 27 ext_model_(0),
27 ext_family_(0), 28 ext_family_(0),
28 has_mmx_(false), 29 has_mmx_(false),
29 has_sse_(false), 30 has_sse_(false),
30 has_sse2_(false), 31 has_sse2_(false),
31 has_sse3_(false), 32 has_sse3_(false),
32 has_ssse3_(false), 33 has_ssse3_(false),
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // before using memcpy to copy these three array elements to cpu_string. 99 // before using memcpy to copy these three array elements to cpu_string.
99 __cpuid(cpu_info, 0); 100 __cpuid(cpu_info, 0);
100 int num_ids = cpu_info[0]; 101 int num_ids = cpu_info[0];
101 std::swap(cpu_info[2], cpu_info[3]); 102 std::swap(cpu_info[2], cpu_info[3]);
102 memcpy(cpu_string, &cpu_info[1], 3 * sizeof(cpu_info[1])); 103 memcpy(cpu_string, &cpu_info[1], 3 * sizeof(cpu_info[1]));
103 cpu_vendor_.assign(cpu_string, 3 * sizeof(cpu_info[1])); 104 cpu_vendor_.assign(cpu_string, 3 * sizeof(cpu_info[1]));
104 105
105 // Interpret CPU feature information. 106 // Interpret CPU feature information.
106 if (num_ids > 0) { 107 if (num_ids > 0) {
107 __cpuid(cpu_info, 1); 108 __cpuid(cpu_info, 1);
109 signature_ = cpu_info[0];
108 stepping_ = cpu_info[0] & 0xf; 110 stepping_ = cpu_info[0] & 0xf;
109 model_ = ((cpu_info[0] >> 4) & 0xf) + ((cpu_info[0] >> 12) & 0xf0); 111 model_ = ((cpu_info[0] >> 4) & 0xf) + ((cpu_info[0] >> 12) & 0xf0);
110 family_ = (cpu_info[0] >> 8) & 0xf; 112 family_ = (cpu_info[0] >> 8) & 0xf;
111 type_ = (cpu_info[0] >> 12) & 0x3; 113 type_ = (cpu_info[0] >> 12) & 0x3;
112 ext_model_ = (cpu_info[0] >> 16) & 0xf; 114 ext_model_ = (cpu_info[0] >> 16) & 0xf;
113 ext_family_ = (cpu_info[0] >> 20) & 0xff; 115 ext_family_ = (cpu_info[0] >> 20) & 0xff;
114 has_mmx_ = (cpu_info[3] & 0x00800000) != 0; 116 has_mmx_ = (cpu_info[3] & 0x00800000) != 0;
115 has_sse_ = (cpu_info[3] & 0x02000000) != 0; 117 has_sse_ = (cpu_info[3] & 0x02000000) != 0;
116 has_sse2_ = (cpu_info[3] & 0x04000000) != 0; 118 has_sse2_ = (cpu_info[3] & 0x04000000) != 0;
117 has_sse3_ = (cpu_info[2] & 0x00000001) != 0; 119 has_sse3_ = (cpu_info[2] & 0x00000001) != 0;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 if (has_sse42()) return SSE42; 153 if (has_sse42()) return SSE42;
152 if (has_sse41()) return SSE41; 154 if (has_sse41()) return SSE41;
153 if (has_ssse3()) return SSSE3; 155 if (has_ssse3()) return SSSE3;
154 if (has_sse3()) return SSE3; 156 if (has_sse3()) return SSE3;
155 if (has_sse2()) return SSE2; 157 if (has_sse2()) return SSE2;
156 if (has_sse()) return SSE; 158 if (has_sse()) return SSE;
157 return PENTIUM; 159 return PENTIUM;
158 } 160 }
159 161
160 } // namespace base 162 } // namespace base
OLDNEW
« no previous file with comments | « base/cpu.h ('k') | chrome/browser/metrics/metrics_log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698