4

Does this question still apply: Why are native ES6 promises slower and more memory-intensive than bluebird??

In regards to the latest versions of Node.js and EC7?

4
10

Yes

I've done some tests and it seems that as of September 2016 Bluebird is still much faster.

For the benchmarks on the Bluebird website, see:

But it's always best to do your own tests for the specific use case that you need. Below are my own tests for very deeply nested promises with a lot of .then and new Promise().

My tests

Here are my tests:

native.js

var P = Promise;
var p = P.resolve('done');
for (var i = 0; i < 1000000; i++) {
  p = p.then(a => new P((res, rej) => res(a)));
}
p.then(console.log);

bluebird.js

var P = require('bluebird');
var p = P.resolve('done');
for (var i = 0; i < 1000000; i++) {
  p = p.then(a => new P((res, rej) => res(a)));
}
p.then(console.log);

Speed

On Node 5.12.0:

$ time node native.js
real    0m5.508s
user    0m5.040s
sys     0m0.385s

$ time node bluebird.js 
real    0m0.968s
user    0m0.861s
sys     0m0.071s

On Node 6.5.0:

$ time node native.js
real    0m7.609s
user    0m7.362s
sys     0m0.260s

$ time node bluebird.js 
real    0m1.053s
user    0m1.033s
sys     0m0.053s

Memory

On Node 5.12.0:

$ /usr/bin/time -v node native.js 2>&1 | grep Maximum
Maximum resident set size (kbytes): 886644

$ /usr/bin/time -v node bluebird.js 2>&1 | grep Maximum
Maximum resident set size (kbytes): 186940

On Node 6.5.0:

$ /usr/bin/time -v node native.js 2>&1 | grep Maximum
Maximum resident set size (kbytes): 767832

$ /usr/bin/time -v node bluebird.js 2>&1 | grep Maximum
Maximum resident set size (kbytes): 187912

It seems that the native Promises are getting slower, if anything.

1
  • ran the same script with node 8.9.1 - and it is still the case that bluebird's promises are faster + lighter: native 0m2.372s and bluebird 0m1.139s. but looks like they are getting closer ... – pkyeck Dec 11 '17 at 17:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.