Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
array addition
(version: 1)
Comparing performance of:
push vs assign
Created:
11 months ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
window.MAX_SIZE = 1000;
Tests:
push
const items = []; for (let i = 0; i < MAX_SIZE; i++) { items.push(i); }
assign
const items = []; for (let i = 0; i < MAX_SIZE; i++) { items[i] = i; }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
push
assign
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
11 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36
Browser/OS:
Chrome 137 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
push
399701.4 Ops/sec
assign
347069.4 Ops/sec
Related benchmarks:
Add item to array: push vs spread vs assign:
For i / For of / ForEach
ForOfFor
array vs []
Add item to array: push vs spread vs assign vs assign+grow
Add item to array: push vs assign
Add item to array: push vs spread vs assign vs assign with from:
javascript loops over string
Add item to array: push vs spread vs assign vs items.length vs items[len++]
Comments
Confirm delete:
Do you really want to delete benchmark?