From 8aed7c65423e2303432e355fa485ef91e830c9d2 Mon Sep 17 00:00:00 2001 From: Alex Christensen Date: Thu, 2 Jul 2015 00:29:55 +0000 Subject: Reduce resolution of performance.now https://bugs.webkit.org/show_bug.cgi?id=146531 rdar://problem/20116796 Reviewed by Simon Fraser. Source/WebCore: Test: http/tests/misc/webtiming-resolution.html * page/Performance.cpp: (WebCore::Performance::now): Floor the time returned by performance.now to the nearest 5 microseconds. LayoutTests: * http/tests/misc/webtiming-resolution-expected.txt: Added. * http/tests/misc/webtiming-resolution.html: Added. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@186208 268f45cc-cd09-0410-ab3c-d52691b4dbfc Change-Id: I24763f8f5d01e4b9c7c92041f981d53d88a0654d Reviewed-by: Allan Sandfeld Jensen --- Source/WebCore/page/Performance.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/WebCore/page/Performance.cpp b/Source/WebCore/page/Performance.cpp index edc4f9153..72b73b16d 100644 --- a/Source/WebCore/page/Performance.cpp +++ b/Source/WebCore/page/Performance.cpp @@ -245,7 +245,9 @@ void Performance::webkitClearMeasures(const String& measureName) double Performance::now() const { - return 1000.0 * (WTF::monotonicallyIncreasingTime() - m_referenceTime); + double nowSeconds = WTF::monotonicallyIncreasingTime() - m_referenceTime; + const double resolutionSeconds = 0.000005; + return 1000.0 * floor(nowSeconds / resolutionSeconds) * resolutionSeconds; } } // namespace WebCore -- cgit v1.2.3