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

Side by Side Diff: chrome/browser/metrics/time_ticks_field_trial_win.cc

Issue 13583007: Create a field trial to test if we can detect good QPC implementations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/metrics/time_ticks_field_trial_win.h"
6
7 #if defined(OS_WIN)
8
9 #include "base/cpu.h"
10 #include "base/metrics/field_trial.h"
11 #include "base/metrics/histogram.h"
12 #include "base/win/windows_version.h"
13
14 #include <windows.h>
15
16 namespace chrome_browser_metrics {
17
18 namespace {
19
20 const int kNumIterations = 1000;
21
22 } // anonymous namespace
23
24 void CollectTimeTicksStats() {
25 // This bit is supposed to indicate that rdtsc is safe across cores. If so, we
26 // can use QPC as long as it uses rdtsc.
27 // TODO(simonjam): We should look for other signals that QPC might be safe and
28 // test them out here.
29 base::CPU cpu;
30 UMA_HISTOGRAM_BOOLEAN("WinTimeTicks.NonStopTsc", cpu.has_nonstoptsc());
31 if (!cpu.has_nonstoptsc()) {
32 return;
33 }
34
35 base::win::OSInfo* info = base::win::OSInfo::GetInstance();
36 UMA_HISTOGRAM_ENUMERATION("WinTimeTicks.VersionTotal", info->version(),
37 base::win::VERSION_WIN_LAST);
38
39 LARGE_INTEGER qpc_frequency;
40 QueryPerformanceFrequency(&qpc_frequency);
41
42 int min_delta = 0;
43 LARGE_INTEGER qpc_last;
44 QueryPerformanceCounter(&qpc_last);
45 for (int i = 0; i < kNumIterations; ++i) {
46 LARGE_INTEGER qpc_now;
47 QueryPerformanceCounter(&qpc_now);
48 int delta = static_cast<int>(qpc_now.QuadPart - qpc_last.QuadPart);
49 if (delta != 0) {
50 min_delta = std::min(min_delta, delta);
51 }
52 qpc_last = qpc_now;
53 }
54
55 UMA_HISTOGRAM_BOOLEAN("WinTimeTicks.NonDecreasing", min_delta > 0);
56 if (min_delta < 0) {
57 return;
jar (doing other things) 2013/04/04 00:26:13 I'm surprised you don't want a histogram of how of
James Simonsen 2013/04/04 02:26:51 Good point. Done.
58 }
59
60 int min_delta_us = static_cast<int>(
61 min_delta * (1e6 / qpc_frequency.QuadPart));
62 UMA_HISTOGRAM_CUSTOM_COUNTS("WinTimeTicks.MinResolutionMicroseconds",
63 min_delta_us, 1, 1000, 50);
64
65 bool success = min_delta_us <= 100; // Our goal is 0.1ms resolution.
66 if (success) {
67 UMA_HISTOGRAM_ENUMERATION("WinTimeTicks.VersionSuccessful",
68 info->version(), base::win::VERSION_WIN_LAST);
69 }
70 }
71
72 } // namespace chrome_browser_net
73
74 #endif // defined(OS_WIN)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698