Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
123456qweess
(version: 0)
hey
Comparing performance of:
loadash vs struct vs recursuve vs json clone
Created:
3 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
var MyObject = { "id": null, "name": "Multi Drop Bucket322101410", "grade": "Grade 6", "status": undefined, "user_id": 2, "version": 2, "grade_id": 149, "item_json": { "uuid": "88ed52c-db67-a72e-5418-a08728b171b", "dropSlot": true, "matchList": [ { "id": "163140-7bbd-ea8b-d8a-2b4ca2b5572", "header": "<p>Category1</p>", "noOfDropSlots": 2 }, { "id": "4384ef8-006e-def8-c11-1d7e5b87fb", "header": "<p>Category2</p>", "noOfDropSlots": 3 } ], "optionList": [ { "id": "1c7a2fd-0574-04d5-48dc-135820a5", "header": "<p>Input1</p>", "dragOptionList": [ { "id": "eeac105-0d43-3e6d-b24a-7807ed84bd6", "optionText": "<p>Option1</p>" }, { "id": "876ae37-dfa6-d221-5d61-0ec718c1dc", "optionText": "<p>Option2</p>" } ] }, { "id": "0732c48-427-62e-2e4-3bd31764e36c", "header": "<p>Input2</p>", "dragOptionList": [ { "id": "28da14-77af-116a-a46d-32cfbc3004", "optionText": "<p>Option3</p>" }, { "id": "f8e507-53d-4b8-3315-d128a6587a04", "optionText": "<p>Option4</p>" } ] } ], "stickyDrop": true, "stemContent": "<p>click <span class=\"text-tag-accessibility\" data-access-id=\"cke-atp-e8d1aca531b57b754cb45c7e264032404\"> Sound</span></p><p> </p>", "itemTypeCode": "MDB", "minItemWidth": 8, "minItemHeight": 9, "correctResponse": [ { "id": "163140-7bbd-ea8b-d8a-2b4ca2b5572", "values": [ "eeac105-0d43-3e6d-b24a-7807ed84bd6" ] }, { "id": "4384ef8-006e-def8-c11-1d7e5b87fb", "values": [] } ] }, "max_score": 34, "rationale": { "optionList": [ { "id": "163140-7bbd-ea8b-d8a-2b4ca2b5572", "rationaleText": "" }, { "id": "4384ef8-006e-def8-c11-1d7e5b87fb", "rationaleText": "" } ] }, "accessArray": [ { "key": "cke-atp-e8d1aca531b57b754cb45c7e264032404", "field": null, "signed": { "Signed_English": { "filePath": "/media/15009/accessibility/item/4004800/86a8fc-234-d4ec-70d0-d41aa34f1231/Lightbulbs%20Moving%20in%20the%20Wind%20%281%29" } }, "spoken": { "textAndGraphics": { "soundPath": "media/15009/accessibility/item/4004800/1717-1187-3ec4-db83-46fcc2f62f1e.mp3", "synthSpeech": " Sound", "defaultOrder": 1, "onDemandOrder": 1 } }, "braille": { "English_Braille": { "filePath": "/media/15009/accessibility/item/4004800/4552544-f7c6-fa8a-f63-2b5fac5a4c6c/brfsample" } }, "keyword": { "DE": "Text6" }, "accommodation_ids": [ 4006886, 4006887, 4006888, 4006889 ] } ], "description": null, "previous_id": null, "content_area": "English Language Arts", "created_date": "2022-10-14T09:36:02.958589+00:00", "item_type_id": 3000168, "scoring_data": { "quotas": [], "scores": [ { "id": "163140-7bbd-ea8b-d8a-2b4ca2b5572", "score": "0", "value": "eeac105-0d43-3e6d-b24a-7807ed84bd6" }, { "id": "4384ef8-006e-def8-c11-1d7e5b87fb", "score": "0", "value": null } ], "rubricId": null, "clusterScoring": null, "rubricViewedBy": null, "allSelectedZero": null, "rubricDirections": "" }, "content_codes": [ "ELA.6.C1" ], "media_library": [], "revision_text": null, "task_user_ids": null, "item_type_code": "MDB", "item_type_name": "Multiple Drop Bucket", "scoring_needed": true, "workflow_tasks": null, "workflow_users": null, "attributes_list": [ { "enemies": null, "friends": null, "group_info": { "grade_id": 149, "content_area_id": 85, "framework_type_ids": [ 411 ] }, "item_usage": 39, "content_codes": [ { "id": 22836, "selection": true, "is_primary": true, "is_secondary": false, "framework_type_id": 411 } ], "testing_program": [ 83 ], "cognitive_category": 354, "cognitive_taxonomy": 282, "estimate_difficulty": 386, "multiple_primary_content_code_needed": [ { "value": true, "framework_type_ids": [] } ] } ], "cluster_scoring": null, "content_area_id": 85, "created_user_id": 2, "framework_types": [ "SBAC-ELA" ], "previous_source": null, "testing_program": "Practice", "variant_type_id": null, "workflow_status": null, "content_code_ids": [ 22836 ], "item_status_code": "final", "item_status_name": "Final", "workflow_task_id": null, "workflow_user_id": null, "created_user_name": "User Two", "is_latest_version": true, "readable_response": null, "scoring_method_id": 62, "accessibility_json": null, "framework_type_ids": [ 411 ], "testing_program_id": "83", "workflow_task_skip": null, "scoring_method_code": "correct_only", "workflow_content_id": null, "workflow_process_id": null, "accessibility_details": null, "assessment_program_id": 15009, "workflow_content_type": null, "workflow_graphic_path": null, "workflow_process_name": null, "assessment_program_ids": null, "assessment_program_code": null, "item_type_category_code": "question", "item_type_category_name": "Question", "workflow_content_type_id": null, "workflow_content_user_ids": null, "workflow_process_description": null }; var myCopy = null; function recursiveDeepCopy(o) { var newO, i; if (typeof o !== 'object') { return o; } if (!o) { return o; } if ('[object Array]' === Object.prototype.toString.apply(o)) { newO = []; for (i = 0; i < o.length; i += 1) { newO[i] = recursiveDeepCopy(o[i]); } return newO; } newO = {}; for (i in o) { if (o.hasOwnProperty(i)) { newO[i] = recursiveDeepCopy(o[i]); } } return newO; }
Tests:
loadash
myCopy = _.cloneDeep(MyObject);
struct
myCopy = structuredClone(MyObject);
recursuve
myCopy = recursiveDeepCopy(MyObject);
json clone
myCopy = JSON.parse(JSON.stringify(MyObject));
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
loadash
struct
recursuve
json clone
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 seems like you're preparing for an upcoming test, perhaps related to JavaScript cloning libraries. To help, I'll provide some insights and code snippets based on the provided data: **Data Analysis** The `myCopy` object is being cloned using different methods: Lodash's `cloneDeep`, `structuredClone`, recursive function (`recursiveDeepCopy`), and JSON parsing with `JSON.parse(JSON.stringify)`. **Lodash (`.cloneDeep`)** Lodash provides a convenient way to deeply clone objects. The benchmark definition suggests that the cloned object is assigned to `myCopy`. ```javascript const _ = require('lodash'); const MyObject = { /* your object */ }; const myCopy = _.cloneDeep(MyObject); ``` **Structured Clone** The `structuredClone` method is a newer, more modern way of cloning objects in JavaScript. The benchmark definition uses this method. ```javascript const MyObject = { /* your object */ }; const myCopy = structuredClone(MyObject); ``` **Recursive Deep Copy** The `recursiveDeepCopy` function provides an alternative implementation for deep cloning objects. The benchmark definition demonstrates its usage. ```javascript function recursiveDeepCopy(o) { // ... } const MyObject = { /* your object */ }; const myCopy = recursiveDeepCopy(MyObject); ``` **JSON Parsing with JSON.stringify** This method involves creating a new JSON string, parsing it as JavaScript, and then assigning the result to `myCopy`. This approach can be more error-prone and less efficient than other methods. ```javascript function cloneWithJson() { const MyObject = { /* your object */ }; const myCopy = JSON.parse(JSON.stringify(MyObject)); } ``` **Benchmark Comparison** To determine which method is the fastest, you'll need to execute each benchmarked function in a test environment and measure their performance. The latest benchmark result suggests that `structuredClone` provides the best execution rate (31557.251953125 executions per second).
Related benchmarks:
Array.map vs reduce
Lodash sortBy vs orderBy two items
Lodash sortBy vs orderBy one item vs two item
Searching for an array element that satisfies certain requirements.
Object, If, Ternary or Switch
Comments
Confirm delete:
Do you really want to delete benchmark?