Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
array addition
(version: 1)
Comparing performance of:
push vs assign
Created:
one year ago
by:
Guest
Go 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:
one year 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
push
400K/s
assign
347K/s
View exact numbers
Test name
Executions per second
✓
push
399,701 Ops/sec
assign
347,069 Ops/sec
Related benchmarks
Add item to array: push vs spread vs assign:
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?