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
Array iteration
<canvas width="512" height="512" id="canvas" style="border: 1px dashed black;">
</canvas>
<script>
var classic = new Array(256);
for (var i = 0; i < 256; i++) {
classic[i] = 0;
}
var context = document.getElementById("canvas").getContext("2d");
var imageData = context.getImageData(0, 0, 256, 256);
var canvas = imageData.data;
if (typeof Uint8Array !== 'undefined') {
var typed8 = new Uint8Array(256);
var typed16 = new Uint16Array(256);
var typed32 = new Uint32Array(256);
var typedF32 = new Float32Array(256);
var typedF64 = new Float64Array(256);
}
for (var i = 0; i < 256; ++i) {
var number = ~~ (Math.random() * 254)
classic[i] = number;
canvas[i] = number;
if (typeof Uint8Array !== 'undefined') {
typed8[i] = number;
typed16[i] = number;
typed32[i] = number;
typedF32 = number;
typedF64 = number;
}
}
context.putImageData(imageData, 0, 0);
</script>
if (typeof Uint8Array === 'undefined') {
throw "Error";
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Classic |
| ready |
Canvas |
| ready |
Typed 8 |
| ready |
Typed 16 |
| ready |
Typed 32 |
| ready |
Typed F32 |
| ready |
Typed F64 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.