promise comparisons

JavaScript performance comparison

Revision 134 of this test case created by Florian

Preparation code

<script src="https://rawgithub.com/calvinmetcalf/lie/1.3.0/dist/lie.noConflict.js"></script>
<script src="https://rsvpjs-builds.s3.amazonaws.com/rsvp-latest.js"></script>
<script src="https://rawgithub.com/calvinmetcalf/catiline/gh-pages/dist/catiline.js"></script>
<script src="https://raw.githubusercontent.com/dfilatov/vow/0.4.7/vow.min.js">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/q.js/1.1.1/q.min.js"></script>
<script src="https://raw.githubusercontent.com/zeusdeux/pimp/0.2.3/browser/pimp.min.js"></script>
<script src="https://raw.githubusercontent.com/petkaantonov/bluebird/v2.3.11/js/browser/bluebird.js">
</script>

<script>
  window.define = function(factory) {
    try {
      delete window.define;
    } catch (e) {
      window.define = void 0;
    } // IE
    window.when = factory();
  };
  window.define.amd = {};
</script>
<script src="https://raw.githubusercontent.com/cujojs/when/3.6.2/when.js">
</script>


    

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
vow
// async test
var d = vow.defer();
var code = 'nat' + Math.random();

function eventFunc(e) {
  if (e.data === code) {
    window.removeEventListener('message', eventFunc);
    d.resolve();

  }
}
window.addEventListener('message', eventFunc);
d.promise().then(function() {
  deferred.resolve()
})
window.postMessage(code, '*');
pending…
lie
// async test
var d = lie();
var code = 'lie' + Math.random();

function eventFunc(e) {
  if (e.data === code) {
    window.removeEventListener('message', eventFunc);
    d.resolve();
  }
}
window.addEventListener('message', eventFunc);
d.promise.then(function() {
  deferred.resolve()
})
window.postMessage(code, '*');
pending…
when
var x = 1;
var d = when.defer()
var code = 'when' + Math.random();

function eventFunc(e) {
  if (e.data === code) {
    window.removeEventListener('message', eventFunc);
    d.resolve();

  }
}
window.addEventListener('message', eventFunc);
d.promise.then(function() {
  deferred.resolve()
})
window.postMessage(code, '*');
pending…
RSVP
// async test
var d = RSVP.defer();
var code = 'rsvp' + Math.random();

function eventFunc(e) {
  if (e.data === code) {
    window.removeEventListener('message', eventFunc);
    d.resolve();

  }
}
window.addEventListener('message', eventFunc);
d.promise.then(function() {
  deferred.resolve()
})
window.postMessage(code, '*');
pending…
q
// async test
var d = Q.defer()
var code = 'q' + Math.random();

function eventFunc(e) {
  if (e.data === code) {
    window.removeEventListener('message', eventFunc);
    d.resolve();

  }
}
window.addEventListener('message', eventFunc);
d.promise.then(function() {
  deferred.resolve()
})
window.postMessage(code, '*');
pending…
catiline
// async test
var d = cw.deferred()
var code = 'cw' + Math.random();

function eventFunc(e) {
  if (e.data === code) {
    window.removeEventListener('message', eventFunc);
    d.resolve();

  }
}
window.addEventListener('message', eventFunc);
d.promise.then(function() {
  deferred.resolve()
})
window.postMessage(code, '*');
pending…
bluebird
var d = P.pending();
var code = 'pend' + Math.random();

function eventFunc(e) {
  if (e.data === code) {
    window.removeEventListener('message', eventFunc);
    d.fulfill();

  }
}

d.promise.then(function() {
  deferred.resolve()
});
window.addEventListener('message', eventFunc);
window.postMessage(code, '*');
pending…
Pimp
// async test
var d = Pimp.deferred()
var code = 'pimp' + Math.random();

function eventFunc(e) {
  if (e.data === code) {
    window.removeEventListener('message', eventFunc);
    d.resolve();

  }
}
window.addEventListener('message', eventFunc);
d.promise.then(function() {
  deferred.resolve()
})
window.postMessage(code, '*');
pending…
Native
// async test
var d = Promise.defer();
var code = 'nat' + Math.random();

function eventFunc(e) {
  if (e.data === code) {
    window.removeEventListener('message', eventFunc);
    d.resolve();

  }
}
window.addEventListener('message', eventFunc);
d.promise.then(function() {
  deferred.resolve()
})
window.postMessage(code, '*');
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.

0 Comments