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 keyPrefix = 'someveryveryveryverylongkeyname_';
const totalItems = 10000;
const totalUndefinedItems = 100000;
const totalReadTimes = totalItems / 5;
const map = {};
const mapWithUndefined = {};
function setupMap() {
for (let i = 1; i <= totalItems; i++) {
map[keyPrefix + (totalItems + i)] = { foo: 'bar'};
mapWithUndefined[keyPrefix + (totalItems + i)] = { foo: 'bar'};
}
for (let i = 1; i <= totalUndefinedItems; i++) {
mapWithUndefined[keyPrefix + (totalItems * 2 + i)] = undefined;
}
}
function loopRead(lookup) {
const step = totalItems / totalReadTimes;
for (let i = 1; i <= totalReadTimes; i++) {
lookup[keyPrefix + (totalItems + Math.floor(step * i))] === undefined;
}
}
setupMap();
Ready to run.
Test | Ops/sec | |
---|---|---|
Read normal map |
| ready |
Read map with huge undefined keys |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.