summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2015-07-27 23:29:03 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2015-07-28 00:13:30 +0200
commit543dabb609226444fae0f9ed10f7b2360b6efda3 (patch)
tree3fda08495f6b2021d5ad481e19bb0b47de8e074e /test
parent3663b124e6edc6df7c076c28bbc41cdc208f8baa (diff)
downloadnode-new-543dabb609226444fae0f9ed10f7b2360b6efda3.tar.gz
timers: improve Timer.now() performance
Record the start time so we can make the return value of Timer.now() relative to it, increasing the chances that it fits in a tagged integer instead of a heap-allocated double, at least for the first one or two billion milliseconds. PR-URL: https://github.com/nodejs/io.js/pull/2256 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-timers-now.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/parallel/test-timers-now.js b/test/parallel/test-timers-now.js
new file mode 100644
index 0000000000..466bd064b8
--- /dev/null
+++ b/test/parallel/test-timers-now.js
@@ -0,0 +1,8 @@
+'use strict';
+
+const common = require('../common');
+const assert = require('assert');
+
+// Return value of Timer.now() should easily fit in a SMI right after start-up.
+const Timer = process.binding('timer_wrap').Timer;
+assert(Timer.now() < 0x3ffffff);