Let timer test retry for 20ms to reduce flakiness.
authormachenbach@chromium.org <machenbach@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 25 Sep 2013 16:47:56 +0000 (16:47 +0000)
committermachenbach@chromium.org <machenbach@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 25 Sep 2013 16:47:56 +0000 (16:47 +0000)
BUG=
R=jkummerow@chromium.org

Review URL: https://codereview.chromium.org/24484003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16948 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

test/mjsunit/timer.js

index 9b8dc29..be7a561 100644 (file)
 
 // Tests timer milliseconds granularity.
 
-var start = Date.now();
-var end = Date.now();
-while (end - start == 0) {
-  end = Date.now();
-}
-assertTrue(end - start <= 2);
+(function run() {
+  var start_test = Date.now();
+  // Let the retry run for maximum 20ms to reduce flakiness.
+  for (var start = Date.now(); start - start_test < 100; start = Date.now()) {
+    var end = Date.now();
+    while (end - start == 0) {
+      end = Date.now();
+    }
+    if (end - start == 1) {
+      // Found milliseconds granularity.
+      return;
+    } else {
+      print("Timer difference too big: " + (end - start) + "ms");
+    }
+  }
+  assertTrue(false);
+})()