Index: test/mjsunit/d8-performance-now.js |
diff --git a/test/mjsunit/regress/regress-grow-store-smi-check.js b/test/mjsunit/d8-performance-now.js |
similarity index 63% |
copy from test/mjsunit/regress/regress-grow-store-smi-check.js |
copy to test/mjsunit/d8-performance-now.js |
index 381141d52317c22cf19547a3626280fa2cb1ba9b..759fed3054bef8281c96c0ec929f4a7aab3dd94b 100644 |
--- a/test/mjsunit/regress/regress-grow-store-smi-check.js |
+++ b/test/mjsunit/d8-performance-now.js |
@@ -27,27 +27,34 @@ |
// Flags: --allow-natives-syntax |
-// The below test function was generated from part of a WebKit layout |
-// test library setup routine: fast/canvas/webgl/resources/pnglib.js |
+// Test the window.performance.now() function of d8. This test only makes |
+// sense with d8. |
-function test(crc32) { |
- for (var i = 0; i < 256; i++) { |
- var c = i; |
- for (var j = 0; j < 8; j++) { |
- if (c & 1) { |
- c = -306674912 ^ ((c >> 1) & 0x7fffffff); |
- } else { |
- c = (c >> 1) & 0x7fffffff; |
- } |
+// Don't run this test in gc stress mode. Time differences may be long |
+// due to garbage collections. |
+%SetFlags("--gc-interval=-1"); |
+%SetFlags("--nostress-compaction"); |
+ |
+(function run() { |
+ var start_test = window.performance.now(); |
+ // Let the retry run for maximum 100ms to reduce flakiness. |
+ for (var start = window.performance.now(); |
+ start - start_test < 100; |
+ start = window.performance.now()) { |
+ var end = window.performance.now(); |
+ assertTrue(start >= start_test); |
+ assertTrue(end >= start); |
+ while (end - start == 0) { |
+ var next = window.performance.now(); |
+ assertTrue(next >= end); |
+ end = next; |
+ } |
+ if (end - start <= 1) { |
+ // Found (sub-)millisecond granularity. |
+ return; |
+ } else { |
+ print("Timer difference too big: " + (end - start) + "ms"); |
} |
- crc32[i] = c; |
} |
-} |
- |
-var a = [0.5]; |
-for (var i = 0; i < 256; ++i) a[i] = i; |
- |
-test([0.5]); |
-test(a); |
-%OptimizeFunctionOnNextCall(test); |
-test(a); |
+ assertTrue(false); |
+})() |