Promise vs Callback (v10)

Revision 10 of this benchmark created by alFReD-NSH on


Test runner

Ready to run.

Testing in
TestOps/sec
Callback
// async test
// async test
function getData(callback) {
  callback();
}

getData(function(data) {
  deferred.resolve()
})
ready
Promise
// async test
var d = deferred;

function getData() {
  return new Promise(function(resolve) {
    setTimeout(function() {
      resolve('data')
    }, 0);
  })
}

getData().then(function(data) {
  d.resolve()
})
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.