Diff
Modified: trunk/LayoutTests/ChangeLog (204735 => 204736)
--- trunk/LayoutTests/ChangeLog 2016-08-22 20:13:36 UTC (rev 204735)
+++ trunk/LayoutTests/ChangeLog 2016-08-22 20:28:39 UTC (rev 204736)
@@ -1,3 +1,15 @@
+2016-08-22 Johan K. Jensen <[email protected]>
+
+ Make NetworkLoadTiming use double for higher precision in Resource Timing
+ https://bugs.webkit.org/show_bug.cgi?id=161051
+
+ Reviewed by Alex Christensen.
+
+ Test that resources timing information are close deltas to a multiple of expected resolution.
+
+ * http/tests/misc/resource-timing-resolution-expected.txt: Added.
+ * http/tests/misc/resource-timing-resolution.html: Added.
+
2016-08-22 Javier Fernandez <[email protected]>
[css-grid] Stretch alignment doesn't work for orthogonal flows
Added: trunk/LayoutTests/http/tests/misc/resource-timing-resolution-expected.txt (0 => 204736)
--- trunk/LayoutTests/http/tests/misc/resource-timing-resolution-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/misc/resource-timing-resolution-expected.txt 2016-08-22 20:28:39 UTC (rev 204736)
@@ -0,0 +1,11 @@
+Verifies the minimum resolution is 5 microseconds.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS t0 !== t1 is true
+PASS shouldBeNearZeroOrOne < 1e-10 || Math.abs(shouldBeNearZeroOrOne - 1) < 1e-10 is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/http/tests/misc/resource-timing-resolution.html (0 => 204736)
--- trunk/LayoutTests/http/tests/misc/resource-timing-resolution.html (rev 0)
+++ trunk/LayoutTests/http/tests/misc/resource-timing-resolution.html 2016-08-22 20:28:39 UTC (rev 204736)
@@ -0,0 +1,36 @@
+<html>
+<head>
+<script src=""
+<script>
+ window.jsTestIsAsync = true;
+ if (window.internals)
+ window.internals.setResourceTimingSupport(true);
+</script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+description("Verifies the minimum resolution is 5 microseconds.");
+var url = ""
+document.write("<img src=''>");
+
+var t0, t1, shouldBeNearZeroOrOne;
+window.addEventListener("load", function() {
+ var entries = performance.getEntries();
+ t0 = entries[0].fetchStart;
+ t1 = entries[1].fetchStart;
+ shouldBe("t0 !== t1", "true");
+
+ var expectedResolutionMilliseconds = 0.005;
+ var integerMultipleOfResolution = (t1 - t0) / expectedResolutionMilliseconds;
+ shouldBeNearZeroOrOne = integerMultipleOfResolution % 1;
+ shouldBe("shouldBeNearZeroOrOne < 1e-10 || Math.abs(shouldBeNearZeroOrOne - 1) < 1e-10", "true");
+ if (window.internals)
+ window.internals.setResourceTimingSupport(false);
+ finishJSTest();
+});
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (204735 => 204736)
--- trunk/Source/WebCore/ChangeLog 2016-08-22 20:13:36 UTC (rev 204735)
+++ trunk/Source/WebCore/ChangeLog 2016-08-22 20:28:39 UTC (rev 204736)
@@ -1,3 +1,38 @@
+2016-08-22 Johan K. Jensen <[email protected]>
+
+ Make NetworkLoadTiming use double for higher precision in Resource Timing
+ https://bugs.webkit.org/show_bug.cgi?id=161051
+
+ Reviewed by Alex Christensen.
+
+ Test: http/tests/misc/resource-timing-resolution.html
+
+ * page/Performance.h:
+ * page/Performance.cpp:
+ (WebCore::Performance::now):
+ (WebCore::Performance::reduceTimeResolution):
+ Add new function to reduce time resolution.
+
+ * page/PerformanceResourceTiming.cpp:
+ (WebCore::monotonicTimeToDocumentMilliseconds):
+ (WebCore::PerformanceResourceTiming::resourceTimeToDocumentMilliseconds):
+ Only use the reduced timing resolution for full timestamps and deltas.
+
+ (WebCore::PerformanceResourceTiming::connectStart): Use doubles.
+ * page/PerformanceResourceTiming.h: Use doubles.
+ * page/PerformanceTiming.cpp: Use doubles.
+ (WebCore::toIntegerMilliseconds): Use doubles.
+ (WebCore::PerformanceTiming::connectStart): Use doubles.
+ (WebCore::PerformanceTiming::resourceLoadTimeRelativeToFetchStart): Use doubles.
+ * page/PerformanceTiming.h: Use doubles.
+ * platform/network/NetworkLoadTiming.h: Use doubles.
+ * platform/network/curl/ResourceHandleManager.cpp: Use doubles.
+ (WebCore::milisecondsSinceRequest): Use doubles.
+ (WebCore::calculateWebTimingInformations): Use doubles.
+ * platform/network/soup/ResourceHandleSoup.cpp: Use doubles.
+ (WebCore::milisecondsSinceRequest): Use doubles.
+ (WebCore::networkEventCallback): Use doubles.
+
2016-08-22 Alex Christensen <[email protected]>
Fix Mac CMake build after r204717.
Modified: trunk/Source/WebCore/page/Performance.cpp (204735 => 204736)
--- trunk/Source/WebCore/page/Performance.cpp 2016-08-22 20:13:36 UTC (rev 204735)
+++ trunk/Source/WebCore/page/Performance.cpp 2016-08-22 20:28:39 UTC (rev 204736)
@@ -218,8 +218,13 @@
double Performance::now() const
{
double nowSeconds = monotonicallyIncreasingTime() - m_referenceTime;
+ return 1000.0 * reduceTimeResolution(nowSeconds);
+}
+
+double Performance::reduceTimeResolution(double seconds)
+{
const double resolutionSeconds = 0.000005;
- return 1000.0 * floor(nowSeconds / resolutionSeconds) * resolutionSeconds;
+ return floor(seconds / resolutionSeconds) * resolutionSeconds;
}
} // namespace WebCore
Modified: trunk/Source/WebCore/page/Performance.h (204735 => 204736)
--- trunk/Source/WebCore/page/Performance.h 2016-08-22 20:13:36 UTC (rev 204735)
+++ trunk/Source/WebCore/page/Performance.h 2016-08-22 20:28:39 UTC (rev 204736)
@@ -83,6 +83,8 @@
void webkitClearMeasures(const String& measureName);
#endif // ENABLE(USER_TIMING)
+ static double reduceTimeResolution(double seconds);
+
private:
explicit Performance(Frame&);
Modified: trunk/Source/WebCore/page/PerformanceResourceTiming.cpp (204735 => 204736)
--- trunk/Source/WebCore/page/PerformanceResourceTiming.cpp 2016-08-22 20:13:36 UTC (rev 204735)
+++ trunk/Source/WebCore/page/PerformanceResourceTiming.cpp 2016-08-22 20:28:39 UTC (rev 204736)
@@ -49,7 +49,7 @@
static double monotonicTimeToDocumentMilliseconds(Document* document, double seconds)
{
ASSERT(seconds >= 0.0);
- return document->loader()->timing().monotonicTimeToZeroBasedDocumentTime(seconds) * 1000.0;
+ return Performance::reduceTimeResolution(document->loader()->timing().monotonicTimeToZeroBasedDocumentTime(seconds)) * 1000.0;
}
static bool passesTimingAllowCheck(const ResourceResponse& response, Document* requestingDocument)
@@ -148,7 +148,7 @@
return domainLookupEnd();
// connectStart includes any DNS time, so we may need to trim that off.
- int connectStart = m_timing.connectStart;
+ double connectStart = m_timing.connectStart;
if (m_timing.domainLookupEnd >= 0)
connectStart = m_timing.domainLookupEnd;
@@ -191,11 +191,13 @@
return monotonicTimeToDocumentMilliseconds(m_requestingDocument.get(), m_finishTime);
}
-double PerformanceResourceTiming::resourceTimeToDocumentMilliseconds(int deltaMilliseconds) const
+double PerformanceResourceTiming::resourceTimeToDocumentMilliseconds(double deltaMilliseconds) const
{
if (!deltaMilliseconds)
return 0.0;
- return monotonicTimeToDocumentMilliseconds(m_requestingDocument.get(), m_requestingDocument->loader()->timing().startTime()) + deltaMilliseconds;
+ double documentStartTime = m_requestingDocument->loader()->timing().monotonicTimeToZeroBasedDocumentTime(m_requestingDocument->loader()->timing().startTime()) * 1000.0;
+ double resourceTimeSeconds = (documentStartTime + deltaMilliseconds) / 1000.0;
+ return 1000.0 * Performance::reduceTimeResolution(resourceTimeSeconds);
}
} // namespace WebCore
Modified: trunk/Source/WebCore/page/PerformanceResourceTiming.h (204735 => 204736)
--- trunk/Source/WebCore/page/PerformanceResourceTiming.h 2016-08-22 20:13:36 UTC (rev 204735)
+++ trunk/Source/WebCore/page/PerformanceResourceTiming.h 2016-08-22 20:28:39 UTC (rev 204736)
@@ -73,7 +73,7 @@
PerformanceResourceTiming(const AtomicString& initatorType, const ResourceRequest&, const ResourceResponse&, double initiationTime, double finishTime, Document*);
~PerformanceResourceTiming();
- double resourceTimeToDocumentMilliseconds(int deltaMilliseconds) const;
+ double resourceTimeToDocumentMilliseconds(double deltaMilliseconds) const;
AtomicString m_initiatorType;
NetworkLoadTiming m_timing;
Modified: trunk/Source/WebCore/page/PerformanceTiming.cpp (204735 => 204736)
--- trunk/Source/WebCore/page/PerformanceTiming.cpp 2016-08-22 20:13:36 UTC (rev 204735)
+++ trunk/Source/WebCore/page/PerformanceTiming.cpp 2016-08-22 20:28:39 UTC (rev 204736)
@@ -40,6 +40,7 @@
#include "FrameLoader.h"
#include "LoadTiming.h"
#include "NetworkLoadTiming.h"
+#include "Performance.h"
#include "ResourceResponse.h"
#include <wtf/CurrentTime.h>
@@ -48,7 +49,8 @@
static unsigned long long toIntegerMilliseconds(double seconds)
{
ASSERT(seconds >= 0);
- return static_cast<unsigned long long>(seconds * 1000.0);
+ double reducedSeconds = Performance::reduceTimeResolution(seconds);
+ return static_cast<unsigned long long>(reducedSeconds * 1000.0);
}
PerformanceTiming::PerformanceTiming(Frame* frame)
@@ -164,7 +166,7 @@
// connectStart will be -1 when a network request is not made.
// Rather than exposing a special value that indicates no new connection, we "backfill" with domainLookupEnd.
- int connectStart = timing.connectStart;
+ double connectStart = timing.connectStart;
if (connectStart < 0)
return domainLookupEnd();
@@ -331,7 +333,7 @@
return &loader->timing();
}
-unsigned long long PerformanceTiming::resourceLoadTimeRelativeToFetchStart(int relativeMilliseconds) const
+unsigned long long PerformanceTiming::resourceLoadTimeRelativeToFetchStart(double relativeMilliseconds) const
{
ASSERT(relativeMilliseconds >= 0);
return fetchStart() + relativeMilliseconds;
Modified: trunk/Source/WebCore/page/PerformanceTiming.h (204735 => 204736)
--- trunk/Source/WebCore/page/PerformanceTiming.h 2016-08-22 20:13:36 UTC (rev 204735)
+++ trunk/Source/WebCore/page/PerformanceTiming.h 2016-08-22 20:28:39 UTC (rev 204736)
@@ -77,7 +77,7 @@
const DocumentTiming* documentTiming() const;
DocumentLoader* documentLoader() const;
LoadTiming* loadTiming() const;
- unsigned long long resourceLoadTimeRelativeToFetchStart(int) const;
+ unsigned long long resourceLoadTimeRelativeToFetchStart(double) const;
unsigned long long monotonicTimeToIntegerMilliseconds(double) const;
};
Modified: trunk/Source/WebCore/platform/network/NetworkLoadTiming.h (204735 => 204736)
--- trunk/Source/WebCore/platform/network/NetworkLoadTiming.h 2016-08-22 20:13:36 UTC (rev 204735)
+++ trunk/Source/WebCore/platform/network/NetworkLoadTiming.h 2016-08-22 20:28:39 UTC (rev 204736)
@@ -93,14 +93,14 @@
template<class Encoder> void encode(Encoder&) const;
template<class Decoder> static bool decode(Decoder&, NetworkLoadTiming&);
- // These are millisecond deltas from the navigation start.
- int domainLookupStart;
- int domainLookupEnd;
- int connectStart;
- int connectEnd;
- int requestStart;
- int responseStart;
- int secureConnectionStart;
+ // These are millisecond deltas from the start time.
+ double domainLookupStart;
+ double domainLookupEnd;
+ double connectStart;
+ double connectEnd;
+ double requestStart;
+ double responseStart;
+ double secureConnectionStart;
};
#if PLATFORM(COCOA)
Modified: trunk/Source/WebCore/platform/network/curl/ResourceHandleManager.cpp (204735 => 204736)
--- trunk/Source/WebCore/platform/network/curl/ResourceHandleManager.cpp 2016-08-22 20:13:36 UTC (rev 204735)
+++ trunk/Source/WebCore/platform/network/curl/ResourceHandleManager.cpp 2016-08-22 20:28:39 UTC (rev 204736)
@@ -169,9 +169,9 @@
}
#if ENABLE(WEB_TIMING)
-static int milisecondsSinceRequest(double requestTime)
+static double milisecondsSinceRequest(double requestTime)
{
- return static_cast<int>((monotonicallyIncreasingTime() - requestTime) * 1000.0);
+ return (monotonicallyIncreasingTime() - requestTime) * 1000.0;
}
static void calculateWebTimingInformations(ResourceHandleInternal* d)
@@ -189,16 +189,16 @@
curl_easy_getinfo(d->m_handle, CURLINFO_PRETRANSFER_TIME, &preTransferTime);
d->m_response.networkLoadTiming().domainLookupStart = 0;
- d->m_response.networkLoadTiming().domainLookupEnd = static_cast<int>(dnslookupTime * 1000);
+ d->m_response.networkLoadTiming().domainLookupEnd = dnslookupTime * 1000;
- d->m_response.networkLoadTiming().connectStart = static_cast<int>(dnslookupTime * 1000);
- d->m_response.networkLoadTiming().connectEnd = static_cast<int>(connectTime * 1000);
+ d->m_response.networkLoadTiming().connectStart = dnslookupTime * 1000;
+ d->m_response.networkLoadTiming().connectEnd = connectTime * 1000;
- d->m_response.networkLoadTiming().requestStart = static_cast<int>(connectTime *1000);
- d->m_response.networkLoadTiming().responseStart =static_cast<int>(preTransferTime * 1000);
+ d->m_response.networkLoadTiming().requestStart = connectTime * 1000;
+ d->m_response.networkLoadTiming().responseStart = preTransferTime * 1000;
if (appConnectTime)
- d->m_response.networkLoadTiming().secureConnectionStart = static_cast<int>(connectTime * 1000);
+ d->m_response.networkLoadTiming().secureConnectionStart = connectTime * 1000;
}
#endif
Modified: trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp (204735 => 204736)
--- trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp 2016-08-22 20:13:36 UTC (rev 204735)
+++ trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp 2016-08-22 20:28:39 UTC (rev 204736)
@@ -238,7 +238,7 @@
static void sendRequestCallback(GObject*, GAsyncResult*, gpointer);
static void readCallback(GObject*, GAsyncResult*, gpointer);
#if ENABLE(WEB_TIMING)
-static int milisecondsSinceRequest(double requestTime);
+static double milisecondsSinceRequest(double requestTime);
#endif
static void continueAfterDidReceiveResponse(ResourceHandle*);
@@ -836,9 +836,9 @@
}
#if ENABLE(WEB_TIMING)
-static int milisecondsSinceRequest(double requestTime)
+static double milisecondsSinceRequest(double requestTime)
{
- return static_cast<int>((monotonicallyIncreasingTime() - requestTime) * 1000.0);
+ return (monotonicallyIncreasingTime() - requestTime) * 1000.0;
}
void ResourceHandle::didStartRequest()
@@ -863,7 +863,7 @@
return;
ResourceHandleInternal* d = handle->getInternal();
- int deltaTime = milisecondsSinceRequest(handle->m_requestTime);
+ double deltaTime = milisecondsSinceRequest(handle->m_requestTime);
switch (event) {
case G_SOCKET_CLIENT_RESOLVING:
d->m_response.networkLoadTiming().domainLookupStart = deltaTime;