Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
[] + push vs new Array() + index insertion (random insertion order)
(version: 1)
Comparing performance of:
[] + push vs new Array() + index insertion
Created:
one year ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const ITEMS_COUNT = 100000 const ITEMS_IN_RANDOM_ORDER = Array.from(Array(ITEMS_COUNT).keys())
Tests:
[] + push
const arr = []; for (const i of ITEMS_IN_RANDOM_ORDER) { arr.push(i); }
new Array() + index insertion
const arr = new Array(ITEMS_COUNT) for (const i of ITEMS_IN_RANDOM_ORDER) { arr[i] = i }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
[] + push
new Array() + index insertion
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Browser/OS:
Chrome 133 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
[] + push
3334.0 Ops/sec
new Array() + index insertion
8032.2 Ops/sec
Related benchmarks:
loopings
loops-perf
testArr insertion
Array Entries vs fori
push vs index123
Add item to array: push vs assign
Various Array constructors vs literal performance (10_000 items)
[] + push vs new Array() + index insertion
[] + push vs new Array() + index insertion (random insertion order) (fixed)
Comments
Confirm delete:
Do you really want to delete benchmark?