js prealloc vs push

Benchmark created on


Setup

const l = 10_000_000

Test runner

Ready to run.

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

Revisions

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