diff options
author | simonjam@chromium.org <simonjam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-10 23:36:08 +0000 |
---|---|---|
committer | simonjam@chromium.org <simonjam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-10 23:36:08 +0000 |
commit | c8e8cb94373c68f39a82e920c469c25f65b9cf5b (patch) | |
tree | c5daf2c91ebf056ff98cb506e47df6c4b1a656a1 /base/threading | |
parent | 61fa77f89e6835141b114528821b214496c2501e (diff) | |
download | chromium_src-c8e8cb94373c68f39a82e920c469c25f65b9cf5b.zip chromium_src-c8e8cb94373c68f39a82e920c469c25f65b9cf5b.tar.gz chromium_src-c8e8cb94373c68f39a82e920c469c25f65b9cf5b.tar.bz2 |
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/23147002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222396 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/threading')
-rw-r--r-- | base/threading/platform_thread_win.cc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/base/threading/platform_thread_win.cc b/base/threading/platform_thread_win.cc index cf1e0f6..e9752ba 100644 --- a/base/threading/platform_thread_win.cc +++ b/base/threading/platform_thread_win.cc @@ -135,7 +135,12 @@ void PlatformThread::YieldCurrentThread() { // static void PlatformThread::Sleep(TimeDelta duration) { - ::Sleep(duration.InMillisecondsRoundedUp()); + // When measured with a high resolution clock, Sleep() sometimes returns much + // too early. We may need to call it repeatedly to get the desired duration. + TimeTicks end = TimeTicks::Now() + duration; + TimeTicks now; + while ((now = TimeTicks::Now()) < end) + ::Sleep((end - now).InMillisecondsRoundedUp()); } // static |