Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
simple deep copy comparison
(version: 0)
compares benchmarks of a few (deep) copy methods
Comparing performance of:
JSON.parse(JSON.stringify()) vs structuredClone vs Spread op vs Object.assign()
Created:
3 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var x = [ { "_id": "63b2e52d50eca4c87ff36b49", "index": 0, "guid": "fcd1d24d-adda-4685-b408-5925d9f142ef", "isActive": true, "balance": "$3,153.72", "picture": "http://placehold.it/32x32", "age": 23, "eyeColor": "brown", "name": "Lindsey Reed", "gender": "female", "company": "SILODYNE", "email": "lindseyreed@silodyne.com", "phone": "+1 (914) 459-2759", "address": "384 McDonald Avenue, Kimmell, Nebraska, 2194", "about": "Deserunt adipisicing labore esse culpa adipisicing consequat dolor voluptate ad adipisicing magna. Sint nostrud Lorem minim minim adipisicing commodo adipisicing reprehenderit id sint sint. Labore do occaecat veniam aute enim voluptate adipisicing sit dolor minim. Laborum ut laboris pariatur dolore culpa consectetur aute reprehenderit ea irure qui occaecat excepteur. Nulla in duis anim labore elit consectetur aliquip nisi eu Lorem reprehenderit commodo.\r\n", "registered": "2018-03-02T05:03:34 -01:00", "latitude": 84.860559, "longitude": 91.806106, "tags": [ "reprehenderit", "eiusmod", "tempor", "laborum", "eu", "anim", "ea" ], "friends": [ { "id": 0, "name": "Odessa Talley" }, { "id": 1, "name": "Miranda Winters" }, { "id": 2, "name": "Wendy Stout" } ], "greeting": "Hello, Lindsey Reed! You have 9 unread messages.", "favoriteFruit": "strawberry" }, { "_id": "63b2e52d9c663a1ac78c8786", "index": 1, "guid": "8cf2ebad-34c3-40d1-b8bb-d89e16e77d36", "isActive": false, "balance": "$2,902.82", "picture": "http://placehold.it/32x32", "age": 23, "eyeColor": "brown", "name": "Violet Cameron", "gender": "female", "company": "PROXSOFT", "email": "violetcameron@proxsoft.com", "phone": "+1 (861) 439-2178", "address": "720 Cambridge Place, Charco, Colorado, 7619", "about": "Qui aliqua velit qui in nostrud duis quis nostrud tempor excepteur nulla quis pariatur tempor. Aliqua dolore aute magna aliquip mollit aliquip tempor laborum proident non deserunt ad adipisicing tempor. Nisi esse adipisicing non commodo do in ad nulla fugiat aute. Cillum pariatur mollit non commodo culpa duis proident ad dolore occaecat cupidatat.\r\n", "registered": "2017-12-24T10:30:37 -01:00", "latitude": 6.186006, "longitude": 38.698713, "tags": [ "anim", "non", "cillum", "laborum", "labore", "nostrud", "quis" ], "friends": [ { "id": 0, "name": "Dejesus Fuentes" }, { "id": 1, "name": "Hillary Jacobs" }, { "id": 2, "name": "Darlene Todd" } ], "greeting": "Hello, Violet Cameron! You have 3 unread messages.", "favoriteFruit": "strawberry" }, { "_id": "63b2e52d0b0a79327838b0da", "index": 2, "guid": "6ee3eb6b-e17e-4072-938d-9d30b39d4839", "isActive": false, "balance": "$2,310.48", "picture": "http://placehold.it/32x32", "age": 21, "eyeColor": "brown", "name": "Todd Serrano", "gender": "male", "company": "NAMEBOX", "email": "toddserrano@namebox.com", "phone": "+1 (987) 585-2991", "address": "763 Barwell Terrace, Dodge, New Jersey, 4706", "about": "Dolor quis minim occaecat ullamco id est consectetur ad aliqua duis pariatur deserunt. Laboris nisi qui nostrud minim elit magna eu id sint non sint ex ullamco. Incididunt nisi labore aliquip magna aute proident reprehenderit fugiat commodo ullamco. Est proident laborum incididunt nulla tempor consectetur irure cupidatat. Et dolore laborum aliqua minim non eiusmod commodo aliqua nisi cupidatat voluptate ut deserunt mollit. Nisi ad ipsum consequat ut sit qui ut reprehenderit dolore nostrud.\r\n", "registered": "2015-08-18T10:48:52 -02:00", "latitude": -56.539321, "longitude": -0.832709, "tags": [ "eiusmod", "proident", "fugiat", "id", "nisi", "ipsum", "tempor" ], "friends": [ { "id": 0, "name": "Amie Mcclure" }, { "id": 1, "name": "Decker Williamson" }, { "id": 2, "name": "Gutierrez Klein" } ], "greeting": "Hello, Todd Serrano! You have 4 unread messages.", "favoriteFruit": "strawberry" }, { "_id": "63b2e52d222b5d212ac163c7", "index": 3, "guid": "c4c2288b-d718-42ae-88c9-cfc85b069578", "isActive": true, "balance": "$3,713.06", "picture": "http://placehold.it/32x32", "age": 39, "eyeColor": "green", "name": "Jimmie Spears", "gender": "female", "company": "VITRICOMP", "email": "jimmiespears@vitricomp.com", "phone": "+1 (891) 543-3465", "address": "168 Senator Street, Eastmont, Maine, 4088", "about": "Id elit commodo quis labore ipsum voluptate nostrud minim dolor et. Magna consectetur minim est labore nostrud voluptate laborum deserunt non ipsum ea occaecat est nulla. Consectetur aliquip adipisicing veniam ut ea enim nisi adipisicing do proident. Esse do nisi anim ipsum reprehenderit cillum sint. Ad qui adipisicing consequat duis excepteur veniam est Lorem sunt sunt.\r\n", "registered": "2020-07-31T11:02:23 -02:00", "latitude": 83.343716, "longitude": -131.584608, "tags": [ "consectetur", "ipsum", "minim", "quis", "quis", "nulla", "cillum" ], "friends": [ { "id": 0, "name": "Mia Park" }, { "id": 1, "name": "Muriel Adkins" }, { "id": 2, "name": "Amber Reyes" } ], "greeting": "Hello, Jimmie Spears! You have 9 unread messages.", "favoriteFruit": "banana" }, { "_id": "63b2e52d739458e938352ca7", "index": 4, "guid": "b3a0b156-ce38-4549-b5a2-1fa5fb6715ff", "isActive": true, "balance": "$2,327.00", "picture": "http://placehold.it/32x32", "age": 25, "eyeColor": "blue", "name": "Pennington Mendez", "gender": "male", "company": "QUIZMO", "email": "penningtonmendez@quizmo.com", "phone": "+1 (832) 438-2788", "address": "886 Drew Street, Groton, Ohio, 9666", "about": "Ad fugiat est officia Lorem adipisicing mollit ex nisi ipsum. Irure aliqua in amet reprehenderit. Culpa Lorem ipsum aute eiusmod velit elit.\r\n", "registered": "2018-07-13T04:33:49 -02:00", "latitude": -44.124601, "longitude": 141.036093, "tags": [ "officia", "nostrud", "velit", "ut", "et", "reprehenderit", "do" ], "friends": [ { "id": 0, "name": "Kelly Padilla" }, { "id": 1, "name": "Chase Ellis" }, { "id": 2, "name": "Angie Savage" } ], "greeting": "Hello, Pennington Mendez! You have 4 unread messages.", "favoriteFruit": "strawberry" }, { "_id": "63b2e52dc02a8273d96417eb", "index": 5, "guid": "b20e2cf2-9867-4788-bf5b-77e517ba696f", "isActive": true, "balance": "$1,796.46", "picture": "http://placehold.it/32x32", "age": 24, "eyeColor": "green", "name": "Virginia Harrell", "gender": "female", "company": "HALAP", "email": "virginiaharrell@halap.com", "phone": "+1 (904) 597-3148", "address": "212 Classon Avenue, Forbestown, Tennessee, 5406", "about": "Cillum velit nisi dolor eu incididunt consectetur in officia et laboris incididunt qui. Officia dolor in amet consectetur eu esse minim dolore eu ex ipsum aliqua esse. Proident nisi sit sint exercitation deserunt ex voluptate mollit occaecat. Quis mollit reprehenderit quis nulla irure aliquip in. Voluptate fugiat do fugiat sint veniam. Enim aute ex proident sit magna voluptate occaecat officia velit in aute excepteur eiusmod.\r\n", "registered": "2016-05-19T05:54:00 -02:00", "latitude": 58.623149, "longitude": -100.201165, "tags": [ "sint", "do", "voluptate", "cupidatat", "Lorem", "magna", "cupidatat" ], "friends": [ { "id": 0, "name": "Burns Jenkins" }, { "id": 1, "name": "Lamb Dickson" }, { "id": 2, "name": "Beverley Andrews" } ], "greeting": "Hello, Virginia Harrell! You have 7 unread messages.", "favoriteFruit": "banana" }, { "_id": "63b2e52dd6dc4c8ddaa6cf64", "index": 6, "guid": "054a97bf-2be2-4707-b6d5-1863617dac1b", "isActive": false, "balance": "$3,374.66", "picture": "http://placehold.it/32x32", "age": 20, "eyeColor": "green", "name": "Lizzie Lambert", "gender": "female", "company": "MINGA", "email": "lizzielambert@minga.com", "phone": "+1 (977) 429-2396", "address": "565 Linwood Street, Jackpot, Oklahoma, 4779", "about": "Duis aliquip et culpa non aute non officia. Esse eu dolore anim aliquip occaecat. Occaecat dolor ad enim ullamco laborum duis aliquip dolore adipisicing occaecat est non quis sint.\r\n", "registered": "2016-05-18T08:22:31 -02:00", "latitude": -64.51267, "longitude": 148.522349, "tags": [ "ad", "magna", "incididunt", "do", "do", "minim", "irure" ], "friends": [ { "id": 0, "name": "Wynn Travis" }, { "id": 1, "name": "Carey Ross" }, { "id": 2, "name": "Christian Nelson" } ], "greeting": "Hello, Lizzie Lambert! You have 7 unread messages.", "favoriteFruit": "apple" } ];
Tests:
JSON.parse(JSON.stringify())
var result = JSON.parse(JSON.stringify(x));
structuredClone
var result = structuredClone(x);
Spread op
var result = {...x};
Object.assign()
var result = Object.assign(x);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
JSON.parse(JSON.stringify())
structuredClone
Spread op
Object.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):
It appears that we are being asked to parse and compare the benchmark results for different methods of cloning or serializing JSON data. To answer this, I will provide an explanation and some code snippets based on the provided information: **Individual test cases:** The individual test cases seem to be benchmarking different methods of cloning or serializing JSON data. The test cases include: * `JSON.parse(JSON.stringify(x))`: This method is used to parse a JSON string into a JavaScript object, which is then converted back into a JSON string using `JSON.stringify()`. * `structuredClone(x)`: This method is a newer, more efficient way of cloning or serializing JavaScript objects. * `var result = {...x};`: This method uses the spread operator (`...`) to clone or serialize the JSON object `x`. * `var result = Object.assign(x);`: This method uses the `Object.assign()` function to clone or serialize the JSON object `x`. **Latest benchmark result:** The latest benchmark result shows the execution times for each of the individual test cases on a Mac OS X 10.15.7 machine running Chrome 107. **Comparison:** Based on the benchmark results, it appears that: * `structuredClone(x)` is the fastest method, with an average execution time of around 39087.25 ms. * `JSON.parse(JSON.stringify(x))` is slower than `structuredClone(x)`, with an average execution time of around 37131.12890625 ms. * The spread operator (`...`) and `Object.assign()` methods are slower than the other two, with average execution times of around 1531912.375 ms and 9500514.0 ms, respectively. Overall, it seems that `structuredClone(x)` is the most efficient method for cloning or serializing JSON data in JavaScript.
Related benchmarks:
Lodash cloneDeep vs JSON Clone (Large Object 2)
Lodash cloneDeep vs native cloneDeep vs dom cloneDeep
Lodash cloneDeep vs native cloneDeep - deepclone only
structuredClose(myObject) vs JSON.parse(JSON.stringify(myObject))
Comments
Confirm delete:
Do you really want to delete benchmark?