From a18c9b7dde22cce6cec5d47cfd6a16694c9992e8 Mon Sep 17 00:00:00 2001 From: Timothy J Fontaine Date: Mon, 10 Mar 2014 14:01:24 -0700 Subject: [PATCH] test: timers-ordering should be more precise Internally we use hrtime to schedule when a timer will fire, to avoid the perils of clock drift or other external operation making time go backward. The timers ordering test should use the same timing mechanism --- test/simple/test-timers-ordering.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/simple/test-timers-ordering.js b/test/simple/test-timers-ordering.js index 0a32d48d593..30cc44e53a6 100644 --- a/test/simple/test-timers-ordering.js +++ b/test/simple/test-timers-ordering.js @@ -21,13 +21,15 @@ var common = require('../common'); var assert = require('assert'); +var Timer = process.binding('timer_wrap').Timer; + var i; var N = 30; var last_i = 0; var last_ts = 0; -var start = Date.now(); +var start = Timer.now(); var f = function(i) { if (i <= N) { @@ -36,7 +38,7 @@ var f = function(i) { last_i = i; // check that this iteration is fired at least 1ms later than the previous - var now = Date.now(); + var now = Timer.now(); console.log(i, now); assert(now >= last_ts + 1, 'current ts ' + now + ' < prev ts ' + last_ts + ' + 1'); last_ts = now;