$ time node nextTick.js
real 0m0.344s
user 0m0.276s
sys 0m0.067s
$ time node setTimeout.js
real 0m9.125s
user 0m8.707s
sys 0m0.410s
Feel free to fork and add your results!
for (var i = 0; i < 1024 * 1024; i++) { | |
process.nextTick(function () { Math.sqrt(i) } ) | |
} |
for (var i = 0; i < 1024 * 1024; i++) { | |
setTimeout(function () { Math.sqrt(i) }, 0) | |
} |
on ubuntu virtual machine
time node nextTick.js
real 0m0.669s
user 0m0.487s
sys 0m0.357s
time node setTimeout.js
real 0m1.513s
user 0m1.709s
sys 0m0.090s