jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
This tests the performance of the Promise.spawn against co.
Note: not all browsers support Generators. As of 14-Feb-2014 this test is known to run in Firefox Nightly
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<script>
$(document).ready(function() {
// thunk
var setTimeoutPromise = function(ms) {
return new Promise(function(resolve, reject){
setTimeout(resolve, ms);
});
};
window.generatorFunction = function*() {
yield setTimeoutPromise(1);
yield setTimeoutPromise(1);
};
window.module = {
exports: null
};
window.runParallel = function(fn, cb) {
var yetToReturn = numCallsToMake = 10000;
var fnCb = function() {
if (0 === --yetToReturn) cb();
};
while (0 < numCallsToMake--) {
fn(fnCb);
}
};
$.getScript("https://raw.github.com/petkaantonov/bluebird/master/js/browser/bluebird.js", function() {
$.getScript("https://raw.github.com/visionmedia/co/master/index.js", function() {
window.co = window.module.exports;
window.bluebirdPrepared = Promise.coroutine(generatorFunction);
window.coPrepared = co(generatorFunction);
console.log('Tools setup');
});
});
});
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Bluebird: Promise.spawn |
| ready |
co |
| ready |
Bluebird: Promise.coroutine (prepared) |
| ready |
co (prepared) |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.