Chromium Code Reviews| 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..82bb3b31381ddca1bc74cd441dc41d36bbe81643 100644 |
| --- a/LayoutTests/http/tests/misc/webtiming-resolution.html |
| +++ b/LayoutTests/http/tests/misc/webtiming-resolution.html |
| @@ -8,17 +8,29 @@ |
| <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(); |
| + 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.
|
| + } |
| + |
| + var expectedResolutionMilliseconds = 0.005; |
| + var integerMultipleOfResolution = (t1 - t0) / expectedResolutionMilliseconds; |
| + shouldBeNearZeroOrOne = integerMultipleOfResolution % 1; |
| + shouldBe("shouldBeNearZeroOrOne < 1e-10 || Math.abs(shouldBeNearZeroOrOne - 1) < 1e-10", "true"); |
| } |
| -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(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.
|
| +testTimeResolution(timeByUserTiming); |
| </script> |
| </body> |
| </html> |