Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
js merge objects
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/142.0.0.0 Safari/537.36
Browser:
Chrome 142
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
5 months ago
Test name
Executions per second
Object.assign mutate
6.3 Ops/sec
Spread new
0.8 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Tests:
Object.assign mutate
function bench(label, fn, iterations = 50) { // Warmup fn(); const t0 = performance.now(); for (let i = 0; i < iterations; i++) fn(); const t1 = performance.now(); console.log(`${label}: ${(t1 - t0).toFixed(2)} ms over ${iterations} runs`); } // Example usage const a = buildOnject(100000); const b = buildOnject(10000); const target1 = structuredClone(a); // or {...a} if shallow const target2 = structuredClone(a); // or {...a} if shallow bench('Object.assign mutate', () => { Object.assign(target1, b); }); function buildOnject(size = 1) { const random = Math.random(1); const out = {}; for (let i = 0; i <= size; i++) { out[random + i] = i; } return out; }
Spread new
function bench(label, fn, iterations = 50) { // Warmup fn(); const t0 = performance.now(); for (let i = 0; i < iterations; i++) fn(); const t1 = performance.now(); console.log(`${label}: ${(t1 - t0).toFixed(2)} ms over ${iterations} runs`); } // Example usage const a = buildOnject(100000); const b = buildOnject(10000); const target1 = structuredClone(a); // or {...a} if shallow const target2 = structuredClone(a); // or {...a} if shallow bench('Spread new', () => { const merged = { ...a, ...b }; }); function buildOnject(size = 1) { const random = Math.random(1); const out = {}; for (let i = 0; i <= size; i++) { out[random + i] = i; } return out; }