Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Performance Spread1
(version: 0)
Comparing performance of:
push vs spread
Created:
3 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var x = new Array(100); for (var i = 0; i < x.length; i++) { x[i] = { item : (new Array(100)).fill(Math.floor(Math.random() * i)) }; } window.top.tests = {aPush:[], aSpread:[]}; window.test = x; window.cutoff = 5000;
Tests:
push
for (let element of window.test) window.top.tests.aPush.push(...element.item); if (window.top.tests.aPush.length > window.cutoff) { window.top.tests.aPush = []; console.log('reset control'); }
spread
for (let element of window.test) window.top.tests.aSpread = [...window.top.tests.aSpread,...element.item]; if (window.top.tests.aSpread.length > window.cutoff) { window.top.tests.aPush = []; console.log('reset control'); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
push
spread
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:
Fill array with random integers
Array.from vs Spread. But with one thousand sequential elements and with one thousand random elements from zero and one thousand.
array.from vs spread with set
.at vs [x]
Adding to an existing array from another (loop, for of, forEach, spread) [1]
Comments
Confirm delete:
Do you really want to delete benchmark?