Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Array initialization: preallocate vs push with objects (1e6)
(version: 1)
Comparing performance of:
Preallocate vs Push
Created:
2 months ago
by:
Guest
Jump to the latest result
Tests:
Preallocate
var N = 1000000; var result = new Array(N); for (var i = 0; i < N; i++) { result[i] = {n: N}; }
Push
var N = 1000000; var result = []; for (var i = 0; i < N; i++) { result.push({n: N}); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Preallocate
Push
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 months ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 Edg/144.0.0.0
Browser/OS:
Chrome 144 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Preallocate
29.4 Ops/sec
Push
147.5 Ops/sec
Related benchmarks:
Array constructor vs literal performance - 1000 items
Array initialization: preallocate vs push
Array initialization: preallocate vs push vs preallocate & fill
Array initialization: preallocate_add_end vs push
Set->Array.from vs iterative pushing
Array initialization: preallocate vs push (Objects)
Array initialization: preallocate vs push with objects
Array initialization: preallocate vs push with objects (200k)
Array initialization: preallocate vs push with objects (500k)
Comments
Confirm delete:
Do you really want to delete benchmark?