Promise vs Callback (v7)

Revision 7 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Promise
// async test
var d = deferred;
var l = 1000;
var a = [];

while(l--) {
    a.push(getData());
}

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


Promise.all(a).then(function(data) {
  d.resolve()
})
ready
Callback
// async test
var d = deferred;
var l = 1000;
var a = [];

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

function cb() {
    l++
    if (l === 999) {
        d.resolve();
    }
    
}

while(l--) {
    a.push(getData(cb));
}
ready

Revisions

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