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 randInt = () => Math.floor(Math.random() * 1_000_000);
const numbers = Array.from({ length: 1000 }, randInt);
const numberObject = {};
numbers.forEach((number) => { numberObject[number] = randInt() })
const numberNPObject = Object.create(null);
numbers.forEach((number) => { numberNPObject[number] = randInt() })
const numberMap = new Map();
numbers.forEach((number) => { numberMap.set(number, randInt()) })
const strings = numbers.map((number) => `key${number}`);
const stringObject = {};
strings.forEach((string) => { stringObject[string] = randInt() });
const stringNPObject = Object.create(null);
strings.forEach((string) => { stringNPObject[string] = randInt() });
const stringMap = new Map();
strings.forEach((string) => { stringMap.set(string, randInt()) });
// shuffle arrays
for (let i = numbers.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[numbers[i], numbers[j]] = [numbers[j], numbers[i]];
[strings[i], strings[j]] = [strings[j], strings[i]];
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Object with numbers |
| ready |
Map with numbers |
| ready |
Object with strings |
| ready |
Map with strings |
| ready |
Object (null proto) with numbers |
| ready |
Object (null proto) with strings |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.