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
Tests to benchamark data locality between arrays, map entries, map keys, map values, object entries, object values. This is used to determine best approach for iterations.
const SIZE = 10_000;
const arr= [];
const preInitArr=arr[SIZE];
const mapInt = new Map();
const mapStr = new Map();
var sum = 0;
for (let i = 0; i < SIZE; i++) {
/*Use random IDs to avoid backing up by arays*/
const id = i + Date.now();
const obj = {id: id, a:getRandomInt(SIZE), b:getRandomInt(SIZE), r:0, idCopy: 0};
arr.push(obj);
mapInt.set(id, obj);
mapStr.set('a' + id, obj);
}
console.log("Map size", mapInt.size);
function getRandomInt(max) {
return Math.floor(Math.random() * max);
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Array foreach |
| ready |
Map with integer key: test entries performance |
| ready |
Array for: const in loop |
| ready |
Map with string key: test entries performance |
| ready |
Map with integer key: test values performance |
| ready |
Map with string key: test values performance |
| ready |
Array for: var outside loop |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.