{"ScriptPreparationCode":null,"TestCases":[{"Name":"Object.assign mutate","Code":"\r\n\r\nfunction bench(label, fn, iterations = 50) {\r\n // Warmup\r\n fn();\r\n const t0 = performance.now();\r\n for (let i = 0; i \u003C iterations; i\u002B\u002B) fn();\r\n const t1 = performance.now();\r\n console.log(\u0060${label}: ${(t1 - t0).toFixed(2)} ms over ${iterations} runs\u0060);\r\n}\r\n\r\n// Example usage\r\nconst a = buildOnject(100000);\r\nconst b = buildOnject(10000);\r\nconst target1 = structuredClone(a); // or {...a} if shallow\r\nconst target2 = structuredClone(a); // or {...a} if shallow\r\n\r\nbench(\u0027Object.assign mutate\u0027, () =\u003E {\r\n Object.assign(target1, b);\r\n});\r\n\r\n\r\nfunction buildOnject(size = 1) {\r\n const random = Math.random(1);\r\n const out = {};\r\n for (let i = 0; i \u003C= size; i\u002B\u002B) {\r\n out[random \u002B i] = i;\r\n }\r\n return out;\r\n}\r\n","IsDeferred":false},{"Name":"Spread new","Code":"\r\n\r\nfunction bench(label, fn, iterations = 50) {\r\n // Warmup\r\n fn();\r\n const t0 = performance.now();\r\n for (let i = 0; i \u003C iterations; i\u002B\u002B) fn();\r\n const t1 = performance.now();\r\n console.log(\u0060${label}: ${(t1 - t0).toFixed(2)} ms over ${iterations} runs\u0060);\r\n}\r\n\r\n// Example usage\r\nconst a = buildOnject(100000);\r\nconst b = buildOnject(10000);\r\nconst target1 = structuredClone(a); // or {...a} if shallow\r\nconst target2 = structuredClone(a); // or {...a} if shallow\r\n\r\nbench(\u0027Spread new\u0027, () =\u003E {\r\n const merged = { ...a, ...b };\r\n});\r\n\r\n\r\nfunction buildOnject(size = 1) {\r\n const random = Math.random(1);\r\n const out = {};\r\n for (let i = 0; i \u003C= size; i\u002B\u002B) {\r\n out[random \u002B i] = i;\r\n }\r\n return out;\r\n}\r\n","IsDeferred":false}]}