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 range1 = (from, to) => {
return new Array(to - from + 1)
.fill()
.map((_, i) => i + from)
}
const range2 = (from, to) => {
return new Array(to - from + 1)
.fill(0)
.map((_, i) => i + from)
}
const range3 = (from, to) => {
return Array.from(
{length: to - from + 1},
(_, i) => i + from
)
}
const range4 = (from, to) => {
const arr = []
for (let i = from; i <= to; ++i) {
arr.push(i)
}
return arr
}
const range5 = (from, to) => {
const len = to - from + 1
const arr = new Array(len)
for (let i = 0; i < len; ++i) {
arr[i] = i + from
}
return arr
}
const range6 = (from, to) => {
const len = to - from + 1
const arr = []
for (let i = 0; i < len; ++i) {
arr[i] = i + from
}
return arr
}
Ready to run.
Test | Ops/sec | |
---|---|---|
new array fill |
| ready |
new array fill 0 |
| ready |
array from |
| ready |
for loop push |
| ready |
for loop prealloc |
| ready |
for loop rely on auto-resize |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.