ShadowNode icon indicating copy to clipboard operation
ShadowNode copied to clipboard

promise: benchmark with v8's builtin ES6 Promise

Open yorkie opened this issue 6 years ago • 0 comments

At my laptop, I get the following results:

$ time node bench-resolve.js 30000
use 30000 tests
done

real	0m0.095s
user	0m0.073s
sys	0m0.018s

$ time node bench-resolve.js 30000 use-fast-promise
use 30000 tests
done

real	0m0.146s
user	0m0.138s
sys	0m0.025s

The use-fast-promise are ShadowNode's builtin promise, it seems that at v8, the builtin Promise is faster than our optimized implementation, we should have the space to increase the performance of Promise.

The following is my script:

const max = process.argv[2];
const useFastPromise = process.argv[3] === 'use-fast-promise';

if (useFastPromise) {
  global.Promise = require('./promise.js');
}

console.log(`use ${max} tests`);
let future = Promise.resolve(true);
for (let i = 0; i < max; i++) {
  future = future.then(() => Promise.resolve(true));
}

future.then(() => {
  console.log('done');
});

/cc @lolBig @legendecas

yorkie avatar Dec 05 '18 15:12 yorkie