Array.push vs index (v3)

Revision 3 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Index arr with holes
const arr = []
for (var i = 0; i < 10; i++) {
   arr[i * 2] = i
}


ready
Array.prototype.push()
const arr = []
for (var i = 0; i < 10; i++) {
   arr.push(i)
}


ready
Index arr
const arr = []
for (var i = 0; i < 10; i++) {
   arr[i] = i
}
ready
Index arr initial size
const arr = new Array(10)
for (var i = 0; i < 10; i++) {
   arr[i] = i
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.