promise comparisons

JavaScript performance comparison

Revision 23 of this test case created by JeanHuguesRobert

Info

This is a comparison of different promise libraries, performing the most basic tasks of creating a promise, adding a then handler and then resolving the promise.

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/dojo/1/dojo/dojo.xd.js"></script>
<script src="http://calvinmetcalf.github.io/promise-jsperf/javascripts/q.js"></script>
<script src="http://calvinmetcalf.github.io/promise-jsperf/javascripts/jQuery.js"></script>
<script src="http://medyk.org/deferred.js"></script>
<script>
    window.define = function(factory) {
        try{ delete window.define; } catch(e){ window.define = void 0; } // IE
        window.when = factory();
    };
    window.define.amd = {};
</script>
<script src="http://calvinmetcalf.github.io/promise-jsperf/javascripts/when.js"></script>
<script src="http://calvinmetcalf.github.io/promise-jsperf/javascripts/rsvp.js"></script>

<script src="http://calvinmetcalf.github.io/promise-jsperf/javascripts/promiscuous-browser.js"></script>
<script src="http://rawgithub.com/JeanHuguesRobert/l8/master/lib/whisper.js"></script>

Preparation code output

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
promiscuous
// async test
var d = promiscuous.deferred();
d.promise.then(function done() {
  deferred.resolve()
})
d.resolve()
pending…
when
// async test
var d = when.defer()
d.promise.then(function done() {
  deferred.resolve()
})
d.resolve()
pending…
jquery
// async test
var d = $.Deferred()
d.then(function done() {
  deferred.resolve()
})
d.resolve()
pending…
RSVP
// async test
var d = RSVP.defer();
d.promise.then(function done() {
  deferred.resolve()
})
d.resolve()
pending…
q
// async test
var d = Q.defer()
d.promise.then(function done() {
  deferred.resolve()
})
d.resolve()
pending…
dojo
// async test
var d = new dojo.Deferred();
d.then(function done() {
  deferred.resolve()
})
d.resolve();
pending…
deferred
// async test
var d = medikooDeferred();
d.promise.then(function () {
  deferred.resolve();
})
d.resolve();
pending…
Parole
// async test
var d = Parole();
d.then( function(){
  deferred.resolve();
});
d( null ) // eqv to d.resolve(), that works too
 
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. Here’s a list of current revisions for this page:

0 comments

Add a comment