arr push vs pre-allocate

Benchmark created on


Setup

const l = 1_000_000

Test runner

Ready to run.

Testing in
TestOps/sec
arr push
const a = []
for (let i = 0; i < l; i++) {
	a.push(i)
}

ready
pre-allocate
const a = Array(l)
for (let i = 0; i < l; i++) {
	a[i] = i
}
ready

Revisions

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