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..13eb1d3f006fa9405873d7e191d733bc4ac37b02 100644 |
--- a/test/mjsunit/regress/regress-grow-store-smi-check.js |
+++ b/test/mjsunit/d8-performance-now.js |
@@ -27,27 +27,36 @@ |
// 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 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); |
+// 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"); |
+ |
+if (this.performance && performance.now) { |
+ (function run() { |
+ var start_test = performance.now(); |
+ // Let the retry run for maximum 100ms to reduce flakiness. |
+ for (var start = performance.now(); |
+ start - start_test < 100; |
+ start = performance.now()) { |
+ var end = performance.now(); |
+ assertTrue(start >= start_test); |
+ assertTrue(end >= start); |
+ while (end - start == 0) { |
+ var next = performance.now(); |
+ assertTrue(next >= end); |
+ end = next; |
+ } |
+ if (end - start <= 1) { |
+ // Found (sub-)millisecond granularity. |
+ return; |
} else { |
- c = (c >> 1) & 0x7fffffff; |
+ print("Timer difference too big: " + (end - start) + "ms"); |
} |
} |
- crc32[i] = c; |
- } |
+ assertTrue(false); |
+ })() |
} |
- |
-var a = [0.5]; |
-for (var i = 0; i < 256; ++i) a[i] = i; |
- |
-test([0.5]); |
-test(a); |
-%OptimizeFunctionOnNextCall(test); |
-test(a); |