angular $q vs bluebird (v12)

Revision 12 of this benchmark created by senc on


Description

Comparison of promise creation and resolution between Angular's $q, bluebird, and native ES6 Promise (only in Chrome and FF).

Preparation HTML

<script>
window.NativePromise = Promise;
</script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.12/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bluebird/2.9.12/bluebird.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/q.js/1.2.0/q.min.js"></script>
<script>
angular.module('app', []).run(['$q', function($q) {
  window.$q = $q;
}]);
</script>
<div ng-app="app"></div>

Test runner

Ready to run.

Testing in
TestOps/sec
Angular Promise instantiate and resolve
// async test
var d = $q.defer();
d.promise.then(function() {
  deferred.resolve.call(deferred);
});
d.resolve('foo');
 
ready
bluebird instantiate and resolve
// async test
var p = new Promise(function(resolve, reject) {
  resolve('foo');
}).
then(function() {
  deferred.resolve()
});
ready
Native
// async test
var p = new NativePromise(function(resolve, reject) {
  resolve('foo');
}).
then(function() {
  deferred.resolve()
});
ready
Q
// async test
var d = Q.defer();
d.promise.then(function() {
  deferred.resolve.call(deferred);
});
d.resolve('foo');
 
ready

Revisions

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