Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Spread vs Object.assign test grmlksdfjk
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Browser:
Chrome 135
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Object.assign two objects
15845.9 Ops/sec
Spread two objects
19808.3 Ops/sec
Object.assign two objects with no empty object first
54681.6 Ops/sec
Script Preparation code:
window.object1 = {}; window.object2 = {}; window.object3 = {}; window.object4 = {}; window.object5 = {}; window.object6 = {}; function makeid() { var text = ""; var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; for (var i = 0; i < 5; i++) text += possible.charAt(Math.floor(Math.random() * possible.length)); return text; }; function populate(object) { for (let i = 0; i < 100; i++) { object[makeid()] = makeid(); } }; populate(object1); populate(object2); populate(object3); populate(object4); populate(object5); populate(object6);
Tests:
Object.assign two objects
const object7 = Object.assign({}, object1, object2);
Spread two objects
const object7 = {...object1, ...object2};
Object.assign two objects with no empty object first
const object7 = Object.assign(object1, object2);