summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndras <andras@kinvey.com>2016-04-27 20:31:59 -0400
committerJeremiah Senkpiel <fishrock123@rocketmail.com>2016-07-05 22:36:43 +0200
commitefb7a90fa959d08eee68c80f2617d50659ffb8e3 (patch)
treeec4725114849756b3841b7141bc859d220050f10 /test
parenta5d894590d090d3f69a04eda6e9c52bbbefcf895 (diff)
downloadnode-new-efb7a90fa959d08eee68c80f2617d50659ffb8e3.tar.gz
timers: optimize `setImmediate()`
Save the setImmediate() callback arguments into an array instead of a closure, and invoke the callback on the arguments from an optimizable function. 60% faster setImmediate with 0 args (15% if self-recursive) 4x faster setImmediate with 1-3 args, 2x with > 3 seems to be faster with less memory pressure when memory is tight Changes: - use L.create() to build faster lists - use runCallback() from within tryOnImmediate() - save the arguments and do not build closures for the callbacks PR-URL: https://github.com/nodejs/node/pull/6436 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-timers-immediate.js6
-rw-r--r--test/parallel/test-timers-linked-list.js4
2 files changed, 8 insertions, 2 deletions
diff --git a/test/parallel/test-timers-immediate.js b/test/parallel/test-timers-immediate.js
index cd0a423f4d..d160adc998 100644
--- a/test/parallel/test-timers-immediate.js
+++ b/test/parallel/test-timers-immediate.js
@@ -5,6 +5,7 @@ var assert = require('assert');
let immediateA = false;
let immediateB = false;
let immediateC = [];
+let immediateD = [];
setImmediate(function() {
try {
@@ -25,8 +26,13 @@ setImmediate(function(x, y, z) {
immediateC = [x, y, z];
}, 1, 2, 3);
+setImmediate(function(x, y, z, a, b) {
+ immediateD = [x, y, z, a, b];
+}, 1, 2, 3, 4, 5);
+
process.on('exit', function() {
assert.ok(immediateA, 'Immediate should happen after normal execution');
assert.notStrictEqual(immediateB, true, 'immediateB should not fire');
assert.deepStrictEqual(immediateC, [1, 2, 3], 'immediateC args should match');
+ assert.deepStrictEqual(immediateD, [1, 2, 3, 4, 5], '5 args should match');
});
diff --git a/test/parallel/test-timers-linked-list.js b/test/parallel/test-timers-linked-list.js
index cdae64d344..4ec7770cfa 100644
--- a/test/parallel/test-timers-linked-list.js
+++ b/test/parallel/test-timers-linked-list.js
@@ -103,8 +103,8 @@ assert.equal(C, L.shift(list));
// list
assert.ok(L.isEmpty(list));
-var list2 = L.create();
-var list3 = L.create();
+const list2 = L.create();
+const list3 = L.create();
assert.ok(L.isEmpty(list2));
assert.ok(L.isEmpty(list3));
assert.ok(list2 != list3);