promise comparisons

JavaScript performance comparison

Revision 5 of this test case created by Marcus Stade

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="http://mstade.github.com/promise-jsperf/javascripts/q.js"></script>
<script src="http://mstade.github.com/promise-jsperf/javascripts/jQuery.js"></script>
<script src="http://mstade.github.com/promise-jsperf/javascripts/when.js"></script>
<script src="http://mstade.github.com/promise-jsperf/javascripts/rsvp.js"></script>
<script src="http://mstade.github.com/promise-jsperf/javascripts/laissez-faire.js"></script>
<script src="http://mstade.github.com/promise-jsperf/javascripts/avow.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
q
// async test
var d = Q.defer()
d.promise.then(function done() {
  deferred.resolve()
})
d.resolve()
pending…
when
// async test
var d = when.defer()
d.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 p = new RSVP.Promise
p.then(function done() {
  deferred.resolve()
})
p.resolve()
pending…
Laissez-faire
// async test
var p = new Promise
p.then(function done() {
  deferred.resolve()
})
p.resolve()
pending…
avow
// async test
var v = avow()
v.promise.then(function done() {
  deferred.resolve()
})
v.fulfill()
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