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

Unified Diff: test/mjsunit/timer.js

Issue 24484003: Let timer test retry for 20ms to reduce flakiness. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/timer.js
diff --git a/test/mjsunit/timer.js b/test/mjsunit/timer.js
index 9b8dc29fe1641f1b79c538413fa00f625d765bce..65a9815b269c48cd89fe118bc3480003cc1d18aa 100644
--- a/test/mjsunit/timer.js
+++ b/test/mjsunit/timer.js
@@ -27,9 +27,20 @@
// 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(){
Jakob Kummerow 2013/09/25 16:16:23 nit: space before '{'
+ var start_test = Date.now();
+ // Let the retry run for maximum 20ms to reduce flakiness.
+ for (var start = Date.now(); start - start_test < 20; start = Date.now()) {
Jakob Kummerow 2013/09/25 16:16:23 I think we can afford a higher upper limit. Maybe
+ var end = Date.now();
+ while (end - start == 0) {
+ end = Date.now();
+ }
+ if (end - start <= 1) {
Jakob Kummerow 2013/09/25 16:16:23 I'd prefer '==' here. 0 can't happen, negative val
+ // Found milliseconds granularity.
+ return;
+ } else {
+ print("Timer difference too big: " + (end - start) + "ms");
+ }
+ }
+ assertTrue(false);
+})()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698