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 map = new Map(Array.from({ length: 10000 }, (_, val) => [val, true]))
const target = 9112
function forOf(map, target) {
let result;
for (const [val] of map) {
if (val === target) {
result = val
}
}
return result
}
function forArr(map, target) {
const arr = Array.from(map)
let result;
for (let i = arr.length - 1; i >= 0; --i) {
if (arr[i][0] === target) {
result = arr[i][0]
}
}
return result
}
function forOfArr(map, target) {
let result;
for (const [val] of Array.from(map)) {
if (val === target) {
result = val
}
}
return result
}
Ready to run.
Test | Ops/sec | |
---|---|---|
for-of |
| ready |
for-reversed |
| ready |
array for-of |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.