promise comparisons

JavaScript performance comparison

Revision 137 of this test case created by

Preparation code

<script>
  // pimp installs a global setImmediate shim
  var _setImmediate = window.setImmediate;
  var _Promise = window.Promise;
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="https://cdn.rawgit.com/dfilatov/vow/0.4.7/vow.min.js"></script>
<script src="https://cdn.rawgit.com/petkaantonov/bluebird/v2.3.11/js/browser/bluebird.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/q.js/1.1.1/q.min.js"></script>
<script src="https://rsvpjs-builds.s3.amazonaws.com/rsvp-latest.js"></script>
<script src="https://cdn.rawgit.com/calvinmetcalf/lie/2.7.7/dist/lie.noConflict.js"></script>
<script src="https://cdn.rawgit.com/calvinmetcalf/catiline/2.9.3/dist/catiline.js"></script>
//kew 0.5.0-alpha1
<script src="http://pastebin.com/raw.php?i=b7R6bgzk"></script>
<script src="https://cdn.rawgit.com/zeusdeux/pimp/0.2.3/browser/pimp.0.2.3.js"></script>
<script>
  window.setImmediate = _setImmediate;
  window.Promise = _Promise;
</script>
    

Preparation code output

//kew 0.5.0-alpha1

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
jquery
// async test
var d = $.Deferred()
d.then(function done() {
  deferred.resolve()
})
d.resolve()
pending…
RSVP
// async test
var d = RSVP.defer();
var code = 'rsvp' + Math.random();

function eventFunc(e) {
  if (e.data === code) {
    window.removeEventListener('message', eventFunc);
    d.resolve();

  }
}
window.addEventListener('message', eventFunc);
d.promise.then(function() {
  deferred.resolve()
})
window.postMessage(code, '*');
pending…
q
// async test
var d = Q.defer()
var code = 'q' + Math.random();

function eventFunc(e) {
  if (e.data === code) {
    window.removeEventListener('message', eventFunc);
    d.resolve();

  }
}
window.addEventListener('message', eventFunc);
d.promise.then(function() {
  deferred.resolve()
})
window.postMessage(code, '*');
pending…
catiline
// async test
var d = cw.deferred()
var code = 'cw' + Math.random();

function eventFunc(e) {
  if (e.data === code) {
    window.removeEventListener('message', eventFunc);
    d.resolve();

  }
}
window.addEventListener('message', eventFunc);
d.promise.then(function() {
  deferred.resolve()
})
window.postMessage(code, '*');
pending…
bluebird
// async test
var d = P.pending();
var code = 'pend' + Math.random();

function eventFunc(e) {
  if (e.data === code) {
    window.removeEventListener('message', eventFunc);
    d.fulfill();

  }
}

d.promise.then(function() {
  deferred.resolve()
});
window.addEventListener('message', eventFunc);
window.postMessage(code, '*');
pending…
Pimp
// async test
var d = Pimp.deferred()
var code = 'pimp' + Math.random();

function eventFunc(e) {
  if (e.data === code) {
    window.removeEventListener('message', eventFunc);
    d.resolve();

  }
}
window.addEventListener('message', eventFunc);
d.promise.then(function() {
  deferred.resolve()
})
window.postMessage(code, '*');
pending…
vow
// async test
var d = vow.defer();
var code = 'nat' + Math.random();

function eventFunc(e) {
  if (e.data === code) {
    window.removeEventListener('message', eventFunc);
    d.resolve();

  }
}
window.addEventListener('message', eventFunc);
d.promise().then(function() {
  deferred.resolve()
})
window.postMessage(code, '*');
pending…
kew
// async test
var d = kew.defer()
var code = 'kew' + Math.random();

function eventFunc(e) {
  if (e.data === code) {
    window.removeEventListener('message', eventFunc);
    d.resolve();
  }
}
window.addEventListener('message', eventFunc);
d.promise.then(function() {
  deferred.resolve()
})
window.postMessage(code, '*');
pending…
Native
// async test
var code = 'native' + Math.random();
var p = new Promise(function(resolve, reject) {
  function eventFunc(e) {
    if (e.data === code) {
      window.removeEventListener('message', eventFunc);
      resolve();
    }
  }
  window.addEventListener('message', eventFunc);
});

p.then(function() {
  deferred.resolve()
})
window.postMessage(code, '*');
pending…
lie
// async test
var code = 'lie' + Math.random();
var p = new Lie(function(resolve, reject) {
  function eventFunc(e) {
    if (e.data === code) {
      window.removeEventListener('message', eventFunc);
      resolve();
    }
  }
  window.addEventListener('message', eventFunc);
});

p.then(function() {
  deferred.resolve()
})
window.postMessage(code, '*');
pending…

Compare results of other browsers

Revisions

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

0 Comments

//kew 0.5.0-alpha1