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
Test out common requestAnimationFrame pollyfill VS setImmediate for the use-case of deferring execution of a function by the shortest amount of time possible.
<script>
var rAF = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
function(fn){ setTimeout(fn, 10); };
var setImmediate = window.setImmediate ||
function(fn) {
var img = new Image();
img.onerror = fn;
img.src = '';
};
var async;
setImmediate(function() {
async = true;
});
async = false;
setTimeout(function() {
console.log(async);
if (async===false) {
throw new Error('setImmediate is not asynchronous.');
}
}, 100);
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
requestAnimationFrame |
| ready |
setImmediate |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.