Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
splice vs reassignment vs arr.length & push
(version: 1)
Compares the speed of array reassignment methods on small arrays for known values
Comparing performance of:
array.splice() vs array.length & push vs reassignment
Created:
3 months ago
by:
Registered User
Jump to the latest result
Script Preparation code:
let array = [1, 2, 3, 4, 5, 6]
Tests:
array.splice()
array.splice(0, 6, 10, 20, 30, 40, 50, 60)
array.length & push
array.length = 0; array.push(10,20,30,40,50,60)
reassignment
array = [10,20,30,40,50,60]
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
array.splice()
array.length & push
reassignment
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
3 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36 Edg/143.0.0.0
Browser/OS:
Chrome 143 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
array.splice()
13979629.0 Ops/sec
array.length & push
13054156.0 Ops/sec
reassignment
7635966.5 Ops/sec
Related benchmarks:
Array Splice vs Splice
Slice vs splice (copy)
splice vs spread operator for adding elements into very large 2D arrays
Slice vs splice 2 ...
array.splice vs array.length
Slice vs Splice vs Shiftxxxxxx
Array.splice(0, N) vs Array.length === N
Replacing array
Empty array: Splice vs Shift
Comments
Confirm delete:
Do you really want to delete benchmark?