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
window.MAX = Math.pow(2, 31) - 1;
window.buf = new ArrayBuffer(8);
window.i32 = new Int32Array(buf);
window.f64 = new Float64Array(buf);
window.advanceHash = function (cur) {
hval ^= cur;
hval = hval + (hval << 1) + (hval << 4) + (hval << 7) + (hval << 8) + (hval << 24);
}
window.writeInt = function (num) {
if (!Number.isSafeInteger(num)) {
debugger;
throw new Error('Invalid non uint value');
}
if (num < 0) {
advanceHash(0);
num = -num;
} else {
advanceHash(1);
}
let rem = num;
if (num > MAX) {
rem = num % MAX;
advanceHash((num / MAX) | 0);
}
advanceHash(rem);
}
window.writeFloat = function (num) {
num = num * 1.0; // coerse to float
f64[0] = num;
advanceHash(i32[0]);
advanceHash(i32[1]);
}
window.hval = 0x811c9dc5;
window.arr = [];
for (let i = 0; i < 200; i++) {
const rand = Math.random();
const val = rand * MAX;
arr.push(Math.floor(val)*0xFF);
}
Ready to run.
Test | Ops/sec | |
---|---|---|
int |
| ready |
float |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.