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

Unified 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: Really add histograms Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/metrics/time_ticks_field_trial_win.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/metrics/time_ticks_field_trial_win.cc
diff --git a/chrome/browser/metrics/time_ticks_field_trial_win.cc b/chrome/browser/metrics/time_ticks_field_trial_win.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f71a55d3bbf41edead907b2dcbc00bf7aad49c1a
--- /dev/null
+++ b/chrome/browser/metrics/time_ticks_field_trial_win.cc
@@ -0,0 +1,77 @@
+// Copyright (c) 2013 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 "chrome/browser/metrics/time_ticks_field_trial_win.h"
+
+#if defined(OS_WIN)
+
+#include "base/cpu.h"
+#include "base/metrics/field_trial.h"
+#include "base/metrics/histogram.h"
+#include "base/win/windows_version.h"
+
+#include <windows.h>
+
+namespace chrome_browser_metrics {
+
+namespace {
+
+const int kNumIterations = 1000;
+
+} // anonymous namespace
+
+void CollectTimeTicksStats() {
+ // This bit is supposed to indicate that rdtsc is safe across cores. If so, we
+ // can use QPC as long as it uses rdtsc.
+ // TODO(simonjam): We should look for other signals that QPC might be safe and
Sigurður Ásgeirsson 2013/04/04 12:35:14 On Windows XP, QPC is going to be a system call ev
+ // test them out here.
+ base::CPU cpu;
+ UMA_HISTOGRAM_BOOLEAN("WinTimeTicks.NonStopTsc",
+ cpu.has_non_stop_time_stamp_counter());
+ if (!cpu.has_non_stop_time_stamp_counter()) {
+ return;
+ }
+
+ base::win::OSInfo* info = base::win::OSInfo::GetInstance();
+ UMA_HISTOGRAM_ENUMERATION("WinTimeTicks.VersionTotal", info->version(),
+ base::win::VERSION_WIN_LAST);
Sigurður Ásgeirsson 2013/04/04 12:35:14 nit: wonky indent.
+
+ LARGE_INTEGER qpc_frequency;
+ QueryPerformanceFrequency(&qpc_frequency);
+
+ int min_delta = 1e9;
+ LARGE_INTEGER qpc_last;
+ QueryPerformanceCounter(&qpc_last);
+ for (int i = 0; i < kNumIterations; ++i) {
+ LARGE_INTEGER qpc_now;
+ QueryPerformanceCounter(&qpc_now);
darin (slow to review) 2013/04/04 06:15:11 Perhaps it would make sense to insert some calls t
Sigurður Ásgeirsson 2013/04/04 12:35:14 You can also deliberately cycle the thread across
jar (doing other things) 2013/04/04 16:58:49 I was thinking about suggesting a sleep... but de
+ int delta = static_cast<int>(qpc_now.QuadPart - qpc_last.QuadPart);
Sigurður Ásgeirsson 2013/04/04 17:17:18 If the whole point of this is to identify when dif
+ if (delta != 0) {
+ min_delta = std::min(min_delta, delta);
+ }
+ qpc_last = qpc_now;
+ }
+
+ if (min_delta >= 0) {
+ UMA_HISTOGRAM_ENUMERATION("WinTimeTicks.NonDecreasing", info->version(),
+ base::win::VERSION_WIN_LAST);
+ } else {
+ return;
+ }
+
+ int min_delta_us = static_cast<int>(
+ min_delta * (1e6 / qpc_frequency.QuadPart));
+ UMA_HISTOGRAM_CUSTOM_COUNTS("WinTimeTicks.MinResolutionMicroseconds",
+ min_delta_us, 1, 1000, 50);
+
+ bool success = min_delta_us <= 100; // Our goal is 0.1ms resolution.
+ if (success) {
+ UMA_HISTOGRAM_ENUMERATION("WinTimeTicks.VersionSuccessful",
+ info->version(), base::win::VERSION_WIN_LAST);
+ }
+}
+
+} // namespace chrome_browser_net
+
+#endif // defined(OS_WIN)
« no previous file with comments | « chrome/browser/metrics/time_ticks_field_trial_win.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698