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
Compares to implementations of symmetricalArrayDiff
function symmetricDifferenceQuadratic(a, b) {
const onlyInA = a.filter(item => !b.includes(item));
const onlyInB = b.filter(item => !a.includes(item));
return {
onlyInA,
onlyInB
};
}
function symmetricDifferenceLinear(a, b) {
const setA = new Set(a);
const setB = new Set(b);
const onlyInA = Array.from(setA).filter(item => !setB.has(item));
const onlyInB = Array.from(setB).filter(item => !setA.has(item));
return {
onlyInA,
onlyInB
};
}
function generateTestData(size) {
// Generate numbers for the first array
const arrayA = Array.from({ length: size }, (_, index) => index);
// Generate numbers for the second array with some overlap.
// For simplicity, we start from size/2 to size + size/2 to create some overlapping and some unique numbers.
const arrayB = Array.from({ length: size }, (_, index) => index + Math.floor(size / 2));
return { arrayA, arrayB };
}
const testDataMin = generateTestData(10);
const testDataSmall = generateTestData(100);
const testDataMedium = generateTestData(1000);
const testDataLarge = generateTestData(100000);
Ready to run.
Test | Ops/sec | |
---|---|---|
quadratic min |
| ready |
linear min |
| ready |
quadratic small |
| ready |
linear small |
| ready |
quadratic medium |
| ready |
linear medium |
| ready |
quadratic large |
| ready |
linear large |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.