promise comparisons (v19)

Revision 19 of this benchmark created by Meryn Stol on


Description

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

Resolve immediately, without any kind of timeout or delay. Don't include setImmediate shim to see how the libs fair on their own.

Preparation HTML

<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="https://code.jquery.com/jquery-2.0.0.min.js"></script>
<script src="http://olostan.org.ua/libs/when.js"></script>
<script src="https://raw.github.com/tildeio/rsvp.js/rsvp2/browser/rsvp.min.js"></script>
<script src="https://raw.github.com/gameclosure/ff/master/lib/ff.js"></script>

<script src="https://raw.github.com/caolan/async/master/lib/async.js"></script>

Test runner

Ready to run.

Testing in
TestOps/sec
when
// async test
var work = function() {
  var d = when.defer()
  d.resolve()
  return d.promise;
}

work().then(function() {
  deferred.resolve();
});
ready
q
// async test
var work = function() {
  var d = Q.defer();
  d.resolve()
  return d.promise;
};

work().then(function() {
  deferred.resolve();
});
ready
jquery
// async test
var work = function() {
  var d = $.Deferred()
  d.resolve()
  return d;
};

work().then(function() {
  deferred.resolve();
});
ready
Vow - jspromise
// async test
var work = function() {
  var vow = Vow.promise();
  vow.fulfill()
  return vow;
};

work().then(function() {
  deferred.resolve();
});
ready
ff
// async test
var work = function() {
  var f = ff.defer();
  f()
  return f;
};

work().then(function() {
  deferred.resolve();
});
ready
rsvp
// async test
var work = function() {
  var rs = new RSVP.Promise(function(resolve, reject) {
    resolve()
  });
  return rs;  
};

work().then(function() {
  deferred.resolve();
});
ready
async
// async test
var work = function(cb) {
  cb();
};
async.series([work], function() {
  deferred.resolve();
});
ready
callback
// async test
var work = function(cb) {
  cb();
};

work(function() {
  deferred.resolve();
});
 
ready

Revisions

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