promise comparisons

JavaScript performance comparison

Test case created by Marcus Stade 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.

Preparation code

<script src="//raw.github.com/kriskowal/q/master/q.js"></script><script src="//raw.github.com/cujojs/when/master/when.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="//raw.github.com/tildeio/rsvp.js/master/browser/rsvp.js"></script>
<script src="//raw.github.com/jkroso/Laissez-faire/master/dist/Laissez-faire.min.js"></script>

<script>module = { exports: {} } // for avow</script>
<script src="//raw.github.com/briancavalier/avow/master/avow.js"></script>
<script>avow = module.exports</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:

1 comment

Marcus Stade (revision owner) commented :

I'd love to get feedback on the validity of these tests. I'm seeing numbers that are wildly different from what has otherwise been reported1. When I run the test Q comes out on top by at least a 2x factor. (I'm using Chrome 23.0.1271 on OSX.)

Add a comment