Promise vs Callback (v11)

Revision 11 of this benchmark created on


Test runner

Ready to run.

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

function getData(callback) {
  setTimeout(function() {
    callback('data')
  }, 100)
}

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

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

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.