Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
spread vs obj assign
(version: 0)
Comparing performance of:
spread vs assign
Created:
6 years ago
by:
Guest
Jump to the latest result
Tests:
spread
const firstObject = { a: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523], b: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, c: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, d: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, e: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, f: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, g: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, h: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, i: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, j: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, k: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, l: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, m: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, n: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, } const secondObject = { 1: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, 2: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, 3: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, 4: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, 5: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, 6: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, 7: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, 8: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, 9: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, 10: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, 11: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, 12: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, 13: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, 14: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, 15: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, 16: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, } const finalObject = { ...firstObject, ...secondObject };
assign
const firstObject = { a: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523], b: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, c: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, d: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, e: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, f: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, g: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, h: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, i: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, j: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, k: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, l: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, m: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, n: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, } const secondObject = { 1: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, 2: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, 3: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, 4: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, 5: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, 6: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, 7: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, 8: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, 9: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, 10: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, 11: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, 12: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, 13: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, 14: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, 15: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, 16: { c: { d: 123, f: [1,2,3,4,5,6,7,34,4,6,6,7,457,34,57,3457,345,73,457,3457,345,734,573,457,3,25,35,23,52,35,235,23,52,35,235,2,35,235,235,23,523] }, dog: { cat: { lizard: "bird"}}}, } const finalObject = Object.assign(firstObject, secondObject);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
spread
assign
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
A long block of code and benchmark results! To answer your question, it appears that the benchmark is comparing the performance of two different methods: 1. `Object.assign()`: used in the code snippet to merge the `firstObject` and `secondObject`. 2. `spread()` (or another method): not shown in the code snippet, but presumably being compared to `Object.assign()`. The results suggest that `Object.assign()` is slightly faster than the other method. Here's a simplified answer: **Object.assign() is generally faster than spread() for merging objects in JavaScript.** However, I must note that the results may vary depending on the specific use case, browser, and environment. Additionally, without more context or information about the `spread()` method being used, it's difficult to provide a definitive answer. Would you like me to elaborate on any of these points?
Related benchmarks:
To fixed vs round vs to precision with float
toFixed() vs Math.round().toString()
toFixed vs Math.round() with numbers222
toFixed vs Math.round vs |(bitwise or)
Array.from vs Spread using 10000 elements
Comments
Confirm delete:
Do you really want to delete benchmark?