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?

bloppit
  • 157
  • 1
  • 2
  • 1
    Run some tests and find out. – Robert Harvey Sep 25 '16 at 15:17
  • 1
    I'm voting to close this question as off topic because it's not about *software development concepts*. Please look at the [help/on-topic] to understand what kinds of questions are acceptable here. Also, any answer to this question would not have any lasting value, since the performance of an implementation could change with any update. – amon Sep 25 '16 at 21:19
  • So where would you suggest this kind of question be asked? – bloppit Sep 26 '16 at 03:22
  • Nowhere at Stack Exchange I'm afraid. ["We already tried supporting those questions, we even gave them their own site. Sadly, it didn't work out..."](http://meta.stackexchange.com/a/200144/165773) – gnat Sep 26 '16 at 07:23

1 Answers1

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.

rsp
  • 7,858
  • 1
  • 17
  • 10
  • 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 ... – Philipp Kyeck Dec 11 '17 at 17:12
  • On node 16.16.0, bluebird is a tiny bit slower, but uses less memory than native. 0m1.064s for bluebird, 0m1.055s for native (fastest of 3 rounds, and in those 3 rounds bluebird was never faster than native). – RedShift Oct 08 '22 at 11:35