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?
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?
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()
.
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);
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
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.