Promise vs Callback (v4)

Revision 4 of this benchmark created by alFReD-NSH on


Setup

var getData = function getData(callback) {
      callback('data');
    };
    
    var getPromise = function () {
      return new Promise(getData)
    };

Test runner

Ready to run.

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

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

getPromise().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.