Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
.concat() (immutable) vs .push() (mutation)
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.4.1 Safari/605.1.15
Browser:
Safari 17
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
concat (immutable)
64899.4 Ops/sec
push (mutability) and spread array
2411.4 Ops/sec
push (mutability) and iteration
1550.4 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
function generateID(length = 10) { const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; let result = ''; const charactersLength = characters.length; for (let i = 0; i < length; i++) { // Generate a random index based on characters length const randomIndex = Math.floor(Math.random() * charactersLength); // Append the character at the random index to the result string result += characters[randomIndex]; } return result; } const initialArray = new Array(10000).fill('a').map(() => ({ [generateID()]: 'value' })); const anotherArray = new Array(10000).fill('b').map(() => ({ [generateID()]: 'value' }));
Tests:
concat (immutable)
const result = initialArray.concat(anotherArray);
push (mutability) and spread array
initialArray.push(...anotherArray);
push (mutability) and iteration
anotherArray.forEach(item => initialArray.push(item));