Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Pushing onto an array in a loop vs pushing with the spread operator
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/148.0.0.0 Safari/537.36
Browser:
Chrome 148
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 months ago
Push with spread
9.0M/s
Push with a for...of loop
6.0M/s
Push with a classic for loop
1.8M/s
View exact numbers
Test name
Executions per second
✓
Push with spread
8,953,680 Ops/sec
Push with a for...of loop
5,973,162 Ops/sec
Push with a classic for loop
1,795,697 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const data = new Array(100); data.fill(1);
Tests:
Push with a for...of loop
const destination = []; for (const elem of data) { destination.push(elem); }
Push with spread
const destination = []; destination.push(...data);
Push with a classic for loop
const destination = []; for (let i = 0; i < data.length; i++) { destination.push(data[i]); }