summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authornhiroki@chromium.org <nhiroki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-13 09:30:11 +0000
committernhiroki@chromium.org <nhiroki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-13 09:30:11 +0000
commit08961e988c34af9ee516fddce99b88ddbbec71a9 (patch)
tree7ce8a6c2c795f90ba858c094b7df314df438024e /base
parentad907cab8a57d73110eec0b75c8e8376497d39a2 (diff)
downloadchromium_src-08961e988c34af9ee516fddce99b88ddbbec71a9.zip
chromium_src-08961e988c34af9ee516fddce99b88ddbbec71a9.tar.gz
chromium_src-08961e988c34af9ee516fddce99b88ddbbec71a9.tar.bz2
Revert 217172 "Enable high resolution time for TimeTicks::Now on..."
There is a suspicion that this might break some tests: MessageLoopTest.PostDelayedTask_InPostOrder_2, StatsTableTest.StatsCounterTimer TimeTicks.Deltas http://build.chromium.org/p/chromium.win/builders/XP%20Tests%20%282%29/builds/30128 http://build.chromium.org/p/chromium.win/builders/Win7%20Tests%20%28dbg%29%281%29/builds/21737 > Enable high resolution time for TimeTicks::Now on Windows Canary > > This should be unnoticeable, except for improved resolution in places such as window.performance.now(). > > The feature is enabled if the user is running Canary channel or has manually specified the --enable-high-resolution-time flag. This will only work if the CPU has a non-stop TSC and isn't a broken Athlon processor. UMA data show this is a safe combination. > > The flag is propagated to renderer processes so that they know to enable it too. > > BUG=158234 > > Review URL: https://chromiumcodereview.appspot.com/16896018 TBR=simonjam@chromium.org Review URL: https://codereview.chromium.org/22984005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217226 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/profiler/tracked_time.cc3
-rw-r--r--base/test/test_suite.cc1
-rw-r--r--base/time/time.h11
-rw-r--r--base/time/time_win.cc48
4 files changed, 6 insertions, 57 deletions
diff --git a/base/profiler/tracked_time.cc b/base/profiler/tracked_time.cc
index 7791c3a..27d3358 100644
--- a/base/profiler/tracked_time.cc
+++ b/base/profiler/tracked_time.cc
@@ -55,7 +55,8 @@ TrackedTime TrackedTime::Now() {
// Use lock-free accessor to 32 bit time.
// Note that TimeTicks::Now() is built on this, so we have "compatible"
// times when we down-convert a TimeTicks sample.
- return TrackedTime(base::TimeTicks::UnprotectedNow());
+ // TODO(jar): Surface this interface via something in base/time/time.h.
+ return TrackedTime(static_cast<int32>(timeGetTime()));
#else
// Posix has nice cheap 64 bit times, so we just down-convert it.
return TrackedTime(base::TimeTicks::Now());
diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc
index 123663a..27c00c9 100644
--- a/base/test/test_suite.cc
+++ b/base/test/test_suite.cc
@@ -96,7 +96,6 @@ void TestSuite::PreInitialize(int argc, char** argv,
bool create_at_exit_manager) {
#if defined(OS_WIN)
testing::GTEST_FLAG(catch_exceptions) = false;
- base::TimeTicks::SetNowIsHighResNowIfSupported();
#endif
base::EnableTerminationOnHeapCorruption();
initialized_command_line_ = CommandLine::Init(argc, argv);
diff --git a/base/time/time.h b/base/time/time.h
index c50bdba..af95700 100644
--- a/base/time/time.h
+++ b/base/time/time.h
@@ -572,17 +572,6 @@ class BASE_EXPORT TimeTicks {
// Returns true if the high resolution clock is working on this system.
// 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
// Returns true if this object has not been initialized.
diff --git a/base/time/time_win.cc b/base/time/time_win.cc
index f35f735..3680ee2a 100644
--- a/base/time/time_win.cc
+++ b/base/time/time_win.cc
@@ -322,12 +322,6 @@ TimeDelta RolloverProtectedNow() {
return TimeDelta::FromMilliseconds(now + rollover_ms);
}
-bool IsBuggyAthlon(const base::CPU& cpu) {
- // On Athlon X2 CPUs (e.g. model 15) QueryPerformanceCounter is
- // unreliable. Fallback to low-res clock.
- return cpu.vendor_name() == "AuthenticAMD" && cpu.family() == 15;
-}
-
// Overview of time counters:
// (1) CPU cycle counter. (Retrieved via RDTSC)
// The CPU counter provides the highest resolution time stamp and is the least
@@ -404,8 +398,10 @@ class HighResNowSingleton {
skew_(0) {
InitializeClock();
+ // On Athlon X2 CPUs (e.g. model 15) QueryPerformanceCounter is
+ // unreliable. Fallback to low-res clock.
base::CPU cpu;
- if (IsBuggyAthlon(cpu))
+ if (cpu.vendor_name() == "AuthenticAMD" && cpu.family() == 15)
DisableHighResClock();
}
@@ -437,24 +433,6 @@ class HighResNowSingleton {
friend struct DefaultSingletonTraits<HighResNowSingleton>;
};
-TimeDelta HighResNowWrapper() {
- return HighResNowSingleton::GetInstance()->Now();
-}
-
-typedef TimeDelta (*NowFunction)(void);
-NowFunction now_function = RolloverProtectedNow;
-
-bool CPUReliablySupportsHighResTime() {
- base::CPU cpu;
- if (!cpu.has_non_stop_time_stamp_counter())
- return false;
-
- if (IsBuggyAthlon(cpu))
- return false;
-
- return true;
-}
-
} // namespace
// static
@@ -469,18 +447,8 @@ 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();
+ return TimeTicks() + RolloverProtectedNow();
}
// static
@@ -515,14 +483,6 @@ bool TimeTicks::IsHighResClockWorking() {
return HighResNowSingleton::GetInstance()->IsUsingHighResClock();
}
-TimeTicks TimeTicks::UnprotectedNow() {
- if (now_function == HighResNowWrapper) {
- return Now();
- } else {
- return TimeTicks() + TimeDelta::FromMilliseconds(timeGetTime());
- }
-}
-
// TimeDelta ------------------------------------------------------------------
// static