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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | LayoutTests/http/tests/misc/webtiming-resolution-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <script src="/js-test-resources/js-test.js"></script> 3 <script src="/js-test-resources/js-test.js"></script>
4 </head> 4 </head>
5 <body> 5 <body>
6 <p id="description"></p> 6 <p id="description"></p>
7 <div id="console"></div> 7 <div id="console"></div>
8 <script> 8 <script>
9 description("Verifies the minimum resolution is 5 microseconds."); 9 description("Verifies the minimum resolution is 5 microseconds.");
10 10
11 var t0 = performance.now(); 11 function testTimeResolution(highResTimeFunc) {
12 var t1 = performance.now(); 12 var t0 = highResTimeFunc();
13 while (t0 == t1) { 13 var t1 = highResTimeFunc();
14 t1 = performance.now(); 14 while (t0 == t1) {
15 t1 = highResTimeFunc();
16 console.log(t1);
inferno 2015/07/07 06:03:46 I don't think you want this line ?
Kunihiko Sakamoto 2015/07/07 06:08:14 Oops, removed.
17 }
18
19 var expectedResolutionMilliseconds = 0.005;
20 var integerMultipleOfResolution = (t1 - t0) / expectedResolutionMilliseconds ;
21 shouldBeNearZeroOrOne = integerMultipleOfResolution % 1;
22 shouldBe("shouldBeNearZeroOrOne < 1e-10 || Math.abs(shouldBeNearZeroOrOne - 1) < 1e-10", "true");
15 } 23 }
16 24
17 var expectedResolutionMilliseconds = 0.005; 25 function timeByUserTiming() {
18 var integerMultipleOfResolution = (t1 - t0) / expectedResolutionMilliseconds; 26 performance.mark('timer');
19 var shouldBeNearZeroOrOne = integerMultipleOfResolution % 1; 27 var t = performance.getEntriesByName('timer')[0].startTime;
20 shouldBe("shouldBeNearZeroOrOne < 1e-10 || Math.abs(shouldBeNearZeroOrOne - 1) < 1e-10", "true"); 28 performance.clearMarks('timer');
29 return t;
30 }
21 31
32 testTimeResolution(function() { return performance.now() });
inferno 2015/07/07 06:03:46 nit: define function() { return performance.now()
Kunihiko Sakamoto 2015/07/07 06:08:14 Done.
33 testTimeResolution(timeByUserTiming);
22 </script> 34 </script>
23 </body> 35 </body>
24 </html> 36 </html>
OLDNEW
« 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