Reputation: 632
I want to know performance difference between bluebird promisify vs promisifyAll.
I have tried performance test of bluebird promisify and promisifyAll.
But time and memory wise i do not see major difference, Still i thought promisify is slightly fast and less memory occupy. Still what is best.
Suppose i want Promisification of renderFile of ejs module for just 1 method renderFile.
I have 2 options
const ejs = require('ejs');
const renderFile = Promise.promisify(ejs.renderFile, {context: ejs});
or
const ejs = Promise.promisifyAll(require('ejs'));
I test performance via
console.time('A');
console.timeEnd('A');
and console.log(process.memoryUsage());
Pls answer about what should i use when i want promisification of only 1 method.
Upvotes: 4
Views: 568
Reputation: 664599
Which method of promisification you are using does not affect the performance of the promisified method at all.
Of course, calling promisify
will do less work than calling promisifyAll
, but since both would be called only once during startup of your program, it does not matter in practice.
Upvotes: 3