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
Compare JS bit operation speed depending on whether the values are coming from a regular array or a typed array.
Expectations:
Outcome: both (2) and (3) seem correct across V8, SpiderMonkey, and JSC. However, (1) only seems to hold in Firefox (where typed array is twice as fast), as the raw array with small numbers performs slightly (10-20%) better on V8 and JSC.
COUNT = 1e6;
const makeRawArray = (offset) => {
const array = [];
for(i = 0; i<COUNT; i++) {
array.push(i + offset)
}
return array;
}
const ra1 = makeRawArray(0);
const ra2 = makeRawArray(0);
const ra1big = makeRawArray(1e31);
const ra2big = makeRawArray(1e31);
const makeTypedArray = (offset) => {
const array = new Uint32Array(COUNT);
for (i = 0; i<COUNT; i++) {
array[i] = i + offset;
}
return array;
}
const ta1 = makeTypedArray(0);
const ta2 = makeTypedArray(0);
const ta1big = makeTypedArray(1e31);
const ta2big = makeTypedArray(1e31);
Ready to run.
Test | Ops/sec | |
---|---|---|
Raw Array |
| ready |
Typed array |
| ready |
Raw Array (>1e31 ints) |
| ready |
Typed Array (>1e31 ints) |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.