Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Array.prototype.concat vs spread operator on small batches
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2.1 Safari/605.1.15
Browser:
Safari 17
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Array.prototype.concat - few iterations
91791.5 Ops/sec
Spread operator - few iterations
38633.2 Ops/sec
Array.prototype.concat - many iterations
1770.4 Ops/sec
Spread operator - many iterations
458.7 Ops/sec
Tests:
Array.prototype.concat - few iterations
const obj = { a: 'string', b: 99 }; const a = Array(50).fill(obj); let b = []; for (let i = 0; i < 20; i++) { b = b.concat(a); }
Spread operator - few iterations
const obj = { a: 'string', b: 99 }; const a = Array(50).fill(obj); let b = []; for (let i = 0; i < 20; i++) { b = [...b, ...a]; }
Array.prototype.concat - many iterations
const obj = { a: 'string', b: 99 }; const a = Array(50).fill(obj); let b = []; for (let i = 0; i < 200; i++) { b = b.concat(a); }
Spread operator - many iterations
const obj = { a: 'string', b: 99 }; const a = Array(50).fill(obj); let b = []; for (let i = 0; i < 200; i++) { b = [...b, ...a]; }