promise comparisons

JavaScript performance comparison

Revision 33 of this test case created and last updated

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.

Removed SLOW laissez-faire Removed avow which has bad code for checking module

Preparation code

<script src="http://mstade.github.com/promise-jsperf/javascripts/q.js"></script>
<script src="https://raw.github.com/dfilatov/jspromise/master/vow.min.js"></script>



<script src="http://ilsken.github.io/promise/async.js"></script>
<script src="http://ilsken.github.io/promise/promise.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://ilsken.github.io/promise/when.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
when
// async test
var d = when.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…
jquery
// async test
var d = $.Deferred()
d.then(function done() {
  deferred.resolve()
})
d.resolve()
pending…
Vow - jspromise
// async test
var vow = Vow.promise();
vow.then(function done() {
 deferred.resolve()
})
vow.fulfill()
pending…
ff
// async test
var f = ff.defer();
f.then(function done() {
  deferred.resolve()
});
f();
pending…
rsvp
// async test
var rs = new RSVP.Promise(function(resolve, reject){
  resolve();
});
rs.then(function done() {
  deferred.resolve();
});
 
pending…
async
// async test
var work = [function(cb) {
  cb();
}];
async.series(work, function() {
  deferred.resolve();
});
pending…
callback
// async test
var node = function(cb) {
  cb();
};

node(function(err) {
  deferred.resolve();
});
 
pending…
then-promise
// async test
new Promise(function(resolve){
     resolve()
}).then(function(){
   deferred.resolve();
})
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