angular $q vs bluebird (v2)

Revision 2 of this benchmark created by caitp on


Description

Simple 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="http://ci.angularjs.org/job/angular.js-caitlin/429/artifact/build/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bluebird/1.2.2/bluebird.min.js"></script>
<script>
window.$q = angular.injector(['ng']).get('$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(function(resolve) {
  resolve('foo');
}).then(function(value) {
  deferred.resolve(value);
});
 
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

Revisions

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