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