Test name | Executions per second |
---|---|
none | 16627.1 Ops/sec |
new | 16091.1 Ops/sec |
length | 16935.1 Ops/sec |
const n = 100;
function getRandomInt(max) {
return Math.floor(Math.random() * max);
}
const arr = [];
for(let i = 0; i < n; ++i) {
arr.push(getRandomInt(1000))
}
const n = 100;
function getRandomInt(max) {
return Math.floor(Math.random() * max);
}
const arrPre = new Array(n);
for(let i = 0; i < n; ++i) {
arrPre[i] = getRandomInt(1000)
}
const n = 100;
function getRandomInt(max) {
return Math.floor(Math.random() * max);
}
const arrLen = []; arrLen.length = n;
for(let i = 0; i < n; ++i) {
arrLen[i] = getRandomInt(1000)
}