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 NR_ELEMENTS = 1000000;
const NR_CHECK = 1000;
function fillArray(nrElements) {
let nrs = [];
let cnt = 0;
let cur = 0;
while (cnt < nrElements) {
if (Math.random() > 0.2) {
nrs.push(cur);
cnt++;
}
cur++;
}
return nrs;
}
const arr = fillArray(NR_ELEMENTS);
const indexedArray = new Array(arr[arr.length - 1]);
indexedArray.fill(false);
for (let i = 0, l = arr.length; i < l; i++) {
indexedArray[arr[i]] = true;
}
const set = new Set();
for (let i = 0, l = arr.length; i < l; i++) {
set.add(arr[i]);
}
const arrayToCheck = fillArray(NR_CHECK);
Ready to run.
Test | Ops/sec | |
---|---|---|
IndexedArray without count |
| ready |
Set without count |
| ready |
IndexedArray with count |
| ready |
Set with count |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.