Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Unified Diff: LayoutTests/http/tests/misc/webtiming-resolution.html

Issue 1216643007: Add test for time resolution of User Timing (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/http/tests/misc/webtiming-resolution-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/http/tests/misc/webtiming-resolution.html
diff --git a/LayoutTests/http/tests/misc/webtiming-resolution.html b/LayoutTests/http/tests/misc/webtiming-resolution.html
index ea0027180edea1a4d0c9e7e8003cb5fc4927199f..812af6acba83755431a922dd40d77bcf1ee770c7 100644
--- a/LayoutTests/http/tests/misc/webtiming-resolution.html
+++ b/LayoutTests/http/tests/misc/webtiming-resolution.html
@@ -8,17 +8,32 @@
<script>
description("Verifies the minimum resolution is 5 microseconds.");
-var t0 = performance.now();
-var t1 = performance.now();
-while (t0 == t1) {
- t1 = performance.now();
+function testTimeResolution(highResTimeFunc) {
+ var t0 = highResTimeFunc();
+ var t1 = highResTimeFunc();
+ while (t0 == t1) {
+ t1 = highResTimeFunc();
+ }
+
+ var expectedResolutionMilliseconds = 0.005;
+ var integerMultipleOfResolution = (t1 - t0) / expectedResolutionMilliseconds;
+ shouldBeNearZeroOrOne = integerMultipleOfResolution % 1;
+ shouldBe("shouldBeNearZeroOrOne < 1e-10 || Math.abs(shouldBeNearZeroOrOne - 1) < 1e-10", "true");
+}
+
+function timeByPerformanceNow() {
+ return performance.now();
}
-var expectedResolutionMilliseconds = 0.005;
-var integerMultipleOfResolution = (t1 - t0) / expectedResolutionMilliseconds;
-var shouldBeNearZeroOrOne = integerMultipleOfResolution % 1;
-shouldBe("shouldBeNearZeroOrOne < 1e-10 || Math.abs(shouldBeNearZeroOrOne - 1) < 1e-10", "true");
+function timeByUserTiming() {
+ performance.mark('timer');
+ var t = performance.getEntriesByName('timer')[0].startTime;
+ performance.clearMarks('timer');
+ return t;
+}
+testTimeResolution(timeByPerformanceNow);
+testTimeResolution(timeByUserTiming);
</script>
</body>
</html>
« no previous file with comments | « no previous file | LayoutTests/http/tests/misc/webtiming-resolution-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698