Promise vs Callback (v2)

Revision 2 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Callback
// async test
var d = deferred;

var test = function(data) {
  d.resolve()
};

function getData() {
  return function(callback) {
    setTimeout(function() {
      callback('data')
    }, 0);
  }
}

getData()(test)
ready
Promise
// async test
var d = deferred;

var test = function(data) {
  d.resolve()
};

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

getData().then(test)
ready

Revisions

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