Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
push() vs [...] for large arrays
Comparing the various ways to append to a large array
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Browser:
Chrome 126
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Push
409444.5 Ops/sec
Spread
42267.1 Ops/sec
Script Preparation code:
window.top.tests = {push:[], spread:[]}; window.test = (new Array(10)).fill(null); window.cutoff = 5000;
Tests:
Push
for (let element of window.test) { window.top.tests.push.push(element); } if (window.top.tests.push.length > window.cutoff) { window.top.tests.push = []; console.log('reset push'); }
Spread
for (let element of window.test) { window.top.tests.spread = [...window.top.tests.spread, element]; } if (window.top.tests.spread.length > window.cutoff) { window.top.tests.spread = []; console.log('reset spread'); }