Bluebird promisify vs promisifyAll Performance comparison when you want to promise one method from a module

I want to know the performance difference between bluebird promisify and promisifyAll.

I tried the bluebird promisify and promisifyAll performance test .

But time and memory are wise, I do not see a significant difference. However, I thought the promise was a little quick and less memory-consuming. Better.

Suppose I want a Promisification of renderFile of an ejs module in just 1 renderFile method.

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 through

console.time('A');
console.timeEnd('A');

and console.log(process.memoryUsage());

Pls answer about what I should use when I want to promote only one method.

+4
1

, , promisified.

, promisify , promisifyAll, , .

+2

Source: https://habr.com/ru/post/1670820/


All Articles