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
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.5.0/lodash.min.js"></script>
const ADAGE_FILTERS_DEFAULT_VALUES = {
domains: [],
students: [],
departments: [],
academies: [],
eventAddressType: "other",
geolocRadius: 50,
formats: [],
venue: null,
}
const getRandomInt = (min, max) => {
return Math.floor(Math.random() * (max - min + 1)) + min;
};
const getRandomString = (length) => {
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
let result = '';
for (let i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * characters.length));
}
return result;
};
const generateFakeVenue = () => {
return {
adageId: Math.random() > 0.5 ? getRandomString(8) : null,
departementCode: getRandomString(2),
id: getRandomInt(1, 1000),
name: getRandomString(10),
publicName: Math.random() > 0.5 ? getRandomString(12) : null,
relative: Array.from({ length: getRandomInt(1, 5) }, () => getRandomInt(1, 1000)),
};
};
const generateFakeFilters = (nbToGenerate) => {
return Array.from({ length: nbToGenerate }, () => ({
domains: Array.from({ length: getRandomInt(1, 5) }, () => getRandomInt(1, 100)),
students: Array.from({ length: getRandomInt(1, 5) }, () => getRandomString(6)),
departments: Array.from({ length: getRandomInt(1, 5) }, () => getRandomString(2)),
academies: Array.from({ length: getRandomInt(1, 5) }, () => getRandomString(3)),
eventAddressType: getRandomString(5),
geolocRadius: getRandomInt(10, 100),
formats: Array.from({ length: getRandomInt(1, 3) }, () => getRandomString(4)),
venue: Math.random() > 0.5 ? generateFakeVenue() : null,
}));
};
const areFiltersEmpty = (filters) => {
return (
filters.domains.length === ADAGE_FILTERS_DEFAULT_VALUES.domains.length &&
filters.departments.length ===
ADAGE_FILTERS_DEFAULT_VALUES.departments.length &&
filters.academies.length ===
ADAGE_FILTERS_DEFAULT_VALUES.academies.length &&
filters.eventAddressType ===
ADAGE_FILTERS_DEFAULT_VALUES.eventAddressType &&
filters.geolocRadius === ADAGE_FILTERS_DEFAULT_VALUES.geolocRadius &&
filters.formats.length === ADAGE_FILTERS_DEFAULT_VALUES.formats.length &&
filters.venue === ADAGE_FILTERS_DEFAULT_VALUES.venue &&
filters.students.length === ADAGE_FILTERS_DEFAULT_VALUES.students.length
)
}
const filters = generateFakeFilters(5000);
Ready to run.
Test | Ops/sec | |
---|---|---|
comparison with "lodash.isEqual" |
| ready |
comparison with "areFiltersEmpty" (manual function) |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.