Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
spread large array (50000 elements) performance (vs slice, splice, concat, for)
(version: 0)
Comparing performance of:
Splice vs Slice vs Concat vs Spread vs For cycle with preallocation
Created:
3 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
testArray = []; for (let i = 0; i < 50000; i++) testArray.push(i)
Tests:
Splice
const newTestArray = testArray.splice(0);
Slice
const newTestArray = testArray.slice();
Concat
const newTestArray = testArray.concat();
Spread
const newTestArray = [...testArray];
For cycle with preallocation
const testArrLen = testArray.length; const resArr = new Array(testArrLen); for (let i = 0; i < testArrLen; i++) { resArr[i] = testArray[i]; }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (5)
Previous results
Fork
Test case name
Result
Splice
Slice
Concat
Spread
For cycle with preallocation
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
Slice vs Spread
spread large array (100 elements) performance (vs slice, splice, concat, for)
Spread vs Slice operators in JS
Array.prototype.slice vs spread operator - Large Arrays
Comments
Confirm delete:
Do you really want to delete benchmark?