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
const SIZES = {
small: 30, // Well under threshold
threshold: 60, // At threshold
large: 120 // Well over threshold
};
// Create arrays with realistic overlap (50% shared elements)
const createArrays = (size, count = 2) => {
const commonElements = Array.from(
{ length: Math.floor(size/2) },
(_, i) => i
);
return Array.from({ length: count }, (_, arrayIndex) => [
...commonElements,
...Array.from(
{ length: Math.floor(size/2) },
(_, i) => size + (arrayIndex * size) + i
)
]);
};
// Small arrays (30 items each, 60 total)
const [smallArr1, smallArr2] = createArrays(SIZES.small);
// Threshold arrays (60 items each, 120 total)
const [thresholdArr1, thresholdArr2] = createArrays(SIZES.threshold);
// Large arrays (120 items each, 240 total)
const [largeArr1, largeArr2] = createArrays(SIZES.large);
// Multi-array versions
const [multiSmall1, multiSmall2, multiSmall3] = createArrays(SIZES.small, 3);
const [multiThreshold1, multiThreshold2, multiThreshold3] = createArrays(SIZES.threshold, 3);
const [multiLarge1, multiLarge2, multiLarge3] = createArrays(SIZES.large, 3);
Ready to run.
Test | Ops/sec | |
---|---|---|
Filter approach - Small arrays |
| ready |
Set approach - Small arrays |
| ready |
Filter approach - Threshold arrays |
| ready |
Set approach - Threshold arrays |
| ready |
Filter approach - Large arrays |
| ready |
Set approach - Large arrays |
| ready |
Filter approach - Small Multi |
| ready |
Set approach - Small Multi |
| ready |
Filter approach - Threshold Multi |
| ready |
Set approach - Threshold Multi |
| ready |
Filter approach - Large Multi |
| ready |
Set approach - Large Multi |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.