summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorfmeawad <fmeawad@chromium.org>2014-08-26 13:10:45 -0700
committerCommit bot <commit-bot@chromium.org>2014-08-26 20:12:51 +0000
commit05399593156ef3b8d96933258cd32fe716f63461 (patch)
tree78a2765a70904253a57f46a95fa03c78dafc860f /base
parent07aef0e93387ef992facfdb9c22716a400f85c46 (diff)
downloadchromium_src-05399593156ef3b8d96933258cd32fe716f63461.zip
chromium_src-05399593156ef3b8d96933258cd32fe716f63461.tar.gz
chromium_src-05399593156ef3b8d96933258cd32fe716f63461.tar.bz2
We have noticed a clock shift when QPC was deployed. It shows as a regression on the perf bots
https://chromeperf.appspot.com/report?masters=ChromiumPerf&bots=chromium-rel-win8-dual&tests=startup.warm.dirty.blank_page%2Fwindow_display_time&rev=286928 It is not a real regression, the initial_time and initial_ticks are not properly initialized when switching to HighResolution (i.e. QPC). This CL initializes the now_function to the HighResNowWrapper instead of setting it to RolloverProtectedNow then to the HighResNowWrapper. By doing that, we avoid getting an incorrect initial_time and initial_ticks using the RolloverProtectedNow and avoid having to reinitialize. BUG=158234 Review URL: https://codereview.chromium.org/446203002 Cr-Commit-Position: refs/heads/master@{#291974}
Diffstat (limited to 'base')
-rw-r--r--base/test/test_suite.cc1
-rw-r--r--base/time/time.h8
-rw-r--r--base/time/time_win.cc50
3 files changed, 20 insertions, 39 deletions
diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc
index 0084d1e..c7a921a 100644
--- a/base/test/test_suite.cc
+++ b/base/test/test_suite.cc
@@ -135,7 +135,6 @@ void TestSuite::InitializeFromCommandLine(int argc, wchar_t** argv) {
void TestSuite::PreInitialize(bool create_at_exit_manager) {
#if defined(OS_WIN)
testing::GTEST_FLAG(catch_exceptions) = false;
- base::TimeTicks::SetNowIsHighResNowIfSupported();
#endif
base::EnableTerminationOnHeapCorruption();
#if defined(OS_LINUX) && defined(USE_AURA)
diff --git a/base/time/time.h b/base/time/time.h
index 79346f1..4d72a19 100644
--- a/base/time/time.h
+++ b/base/time/time.h
@@ -639,14 +639,6 @@ class BASE_EXPORT TimeTicks {
// This is only for testing.
static bool IsHighResClockWorking();
- // Enable high resolution time for TimeTicks::Now(). This function will
- // test for the availability of a working implementation of
- // QueryPerformanceCounter(). If one is not available, this function does
- // nothing and the resolution of Now() remains 1ms. Otherwise, all future
- // calls to TimeTicks::Now() will have the higher resolution provided by QPC.
- // Returns true if high resolution time was successfully enabled.
- static bool SetNowIsHighResNowIfSupported();
-
// Returns a time value that is NOT rollover protected.
static TimeTicks UnprotectedNow();
#endif
diff --git a/base/time/time_win.cc b/base/time/time_win.cc
index 5fa899d..27bcd18 100644
--- a/base/time/time_win.cc
+++ b/base/time/time_win.cc
@@ -359,21 +359,24 @@ bool IsBuggyAthlon(const base::CPU& cpu) {
class HighResNowSingleton {
public:
HighResNowSingleton()
- : ticks_per_second_(0),
- skew_(0) {
- InitializeClock();
+ : ticks_per_second_(0),
+ skew_(0) {
base::CPU cpu;
if (IsBuggyAthlon(cpu))
- DisableHighResClock();
- }
+ return;
- bool IsUsingHighResClock() {
- return ticks_per_second_ != 0.0;
+ // Synchronize the QPC clock with GetSystemTimeAsFileTime.
+ LARGE_INTEGER ticks_per_sec = {0};
+ if (!QueryPerformanceFrequency(&ticks_per_sec))
+ return; // QPC is not available.
+ ticks_per_second_ = ticks_per_sec.QuadPart;
+
+ skew_ = UnreliableNow() - ReliableNow();
}
- void DisableHighResClock() {
- ticks_per_second_ = 0.0;
+ bool IsUsingHighResClock() {
+ return ticks_per_second_ != 0;
}
TimeDelta Now() {
@@ -408,16 +411,6 @@ class HighResNowSingleton {
}
private:
- // Synchronize the QPC clock with GetSystemTimeAsFileTime.
- void InitializeClock() {
- LARGE_INTEGER ticks_per_sec = {0};
- if (!QueryPerformanceFrequency(&ticks_per_sec))
- return; // Broken, we don't guarantee this function works.
- ticks_per_second_ = ticks_per_sec.QuadPart;
-
- skew_ = UnreliableNow() - ReliableNow();
- }
-
// Get the number of microseconds since boot in an unreliable fashion.
int64 UnreliableNow() {
LARGE_INTEGER now;
@@ -446,7 +439,6 @@ TimeDelta HighResNowWrapper() {
}
typedef TimeDelta (*NowFunction)(void);
-NowFunction now_function = RolloverProtectedNow;
bool CPUReliablySupportsHighResTime() {
base::CPU cpu;
@@ -460,6 +452,14 @@ bool CPUReliablySupportsHighResTime() {
return true;
}
+NowFunction GetNowFunction() {
+ if (!CPUReliablySupportsHighResTime())
+ return RolloverProtectedNow;
+ return HighResNowWrapper;
+}
+
+NowFunction now_function = GetNowFunction();
+
} // namespace
// static
@@ -474,16 +474,6 @@ TimeTicks::TickFunctionType TimeTicks::SetMockTickFunction(
}
// static
-bool TimeTicks::SetNowIsHighResNowIfSupported() {
- if (!CPUReliablySupportsHighResTime()) {
- return false;
- }
-
- now_function = HighResNowWrapper;
- return true;
-}
-
-// static
TimeTicks TimeTicks::Now() {
return TimeTicks() + now_function();
}