Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Concat vs push(...) for large arrays 223123
(version: 1)
Comparing the various ways to append to a large array
Comparing performance of:
Control (for push) vs Concat vs Spread vs Spread 2
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
window.top.tests = {control:[], concat:[], spread:[]}; window.test = (new Array(10)).fill(null); window.cutoff = 5000;
Tests:
Control (for push)
for (let element of window.test) window.top.tests.control.push(element);
Concat
window.top.tests.concat = window.top.tests.concat.concat(window.test);
Spread
window.top.tests.spread.push(...window.test);
Spread 2
window.top.tests.spread = [window.top.tests.spread, ...window.test];
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
Control (for push)
Concat
Spread
Spread 2
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
11 days ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:149.0) Gecko/20100101 Firefox/149.0
Browser/OS:
Firefox 149 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Control (for push)
253306.8 Ops/sec
Concat
2533.7 Ops/sec
Spread
1042726.5 Ops/sec
Spread 2
545452.7 Ops/sec
Related benchmarks:
Concat vs push(...) for large arrays
Concat vs push(...) vs spread for large arrays
Concat vs push(...) for large arrays using spread in test 2
gmoney - Concat vs push(...) for large arrays
Concat vs push(...) vs push.apply for large arrays
FD Concat vs push(...) for large arrays
Concat vs push vs spread for large arrays 2
Concat vs push(...) for large arrays 222
for loop vs concat vs push(...) vs push.apply for large arrays
Comments
Confirm delete:
Do you really want to delete benchmark?