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 = Array.from({ length: 10000 }, (_, val) => val + 1)
const lowTarget = 1127
const highTarget = 9116
function forIn(list, target) {
for (const val in list) {
if (val === target) {
return val
}
}
}
function forOf(list, target) {
for (const val of list) {
if (val === target) {
return val
}
}
}
function findReversed(list, target) {
for (let i = list.length - 1; i >= 0; --i) {
if (list[i] === target) {
return list[i]
}
}
}
function find(list, target) {
for (let i = 0; i < list.length; i++) {
if (list[i] === target) {
return list[i]
}
}
}
Ready to run.
Test | Ops/sec | |
---|---|---|
forIn (low) |
| ready |
forIn (high) |
| ready |
forOf (low) |
| ready |
forOf (high) |
| ready |
for-loop (low) |
| ready |
for-loop (high) |
| ready |
for-loop reversed (low) |
| ready |
for-loop reversed (high) |
| ready |
Array.find |
| ready |
Array.findIndex |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.