Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Array insert
(version: 2)
Comparing performance of:
push vs unshift vs set vs push + reverse
Created:
2 months ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Tests:
push
const arr = [] for (let i = 0; i < 10000; i++) { arr.push(Math.random()) }
unshift
const arr = [] for (let i = 0; i < 10000; i++) { arr.unshift(Math.random()) }
set
const arr = new Array(10000) for (let i = 0; i < 10000; i++) { arr[i] = Math.random() }
push + reverse
const arr = [] for (let i = 0; i < 10000; i++) { arr.push(Math.random()) } const newArr = arr.reverse()
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
push
unshift
set
push + reverse
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36
Browser/OS:
Chrome 145 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
push
11007.5 Ops/sec
unshift
214.0 Ops/sec
set
22414.6 Ops/sec
push + reverse
10112.1 Ops/sec
Related benchmarks:
loopings
loops-perf
fast deep clone array
testArr insertion
Array Entries vs fori
pre fill array
length = 0 vs reassignment
Array last index
while, for, for-of, map
Comments
Confirm delete:
Do you really want to delete benchmark?