Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash cloneDeep vs structuredClone vs JSON Parse 2023
(version: 0)
https://developer.mozilla.org/en-US/docs/Web/API/structuredClone
Comparing performance of:
Lodash cloneDeep vs Native structuredClone vs JSON Parse
Created:
3 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.min.js'></script>
Script Preparation code:
var MyObject = { "page": { "report": { "id": 8605, "name": 8605, "components": [ { "id": "root", "name": "页面", "componentName": "Root", "componentType": "container", "props": { "relatedFilterContainerId": "Filter_global", "common": {}, "format": { "layout": { "cols": 24, "gap": 10 }, "pageConfig": { "layoutMode": "grid", "freeGridSticky": true } } } }, { "id": "Filter_global", "name": "全局筛选", "componentName": "Filter", "componentType": "container", "props": { "format": { "styleConfig": { "showQueryButton": true } } } }, { "id": "Chart_e5fwOQi4gu", "name": "明细表格[i4gu]", "componentName": "ProTable", "componentType": "chart", "props": { "editExt": {}, "format": { "titleConfig": { "enable": true, "size": "medium", "showTotal": true }, "toolbarConfig": { "enable": true }, "styleConfig": { "size": "medium", "ghost": false, "hasBorder": true, "isZebra": true }, "customSettingConfig": { "enable": true, "calcByCustomDims": true, "iconType": "show-text" }, "paginationConfig": { "enable": true, "defaultPageSize": 10, "type": "normal", "size": "medium", "hideOnlyOnePage": false }, "rowSelectionConfig": { "width": 50, "lock": true } } }, "dataSource": { "label": "测试", "code": "1341", "type": "dataset", "originType": "file", "originCode": "b20b28ad-9a31-4166-a663-27ffd626fc54", "isMultiDim": false, "isSelfAnalytic": true, "props": { "permissionType": [ 1, 2, 3 ], "applyPermissionItem": [], "allowApply": 1, "secretLevel": 2, "dataMaxZoneConfig": { "ptKey": "ds", "ptRange": 30 }, "dataDownloadByDataShare": { "switch": [ "true" ] }, "driverType": "hologresDriver", "originDatabaseName": "", "originTableName": "-" } }, "fields": [ { "id": "field_QejV1RmLUb", "fieldType": "dimension", "processType": "", "dataType": "date", "originCode": "日期", "code": "日期-5d4c1f", "originLabel": "日期", "label": "日期", "formula": { "timeType": "YYYY-MM-DD" }, "ext": {}, "props": { "sortable": true, "textFormatConfig": { "formatType": "date" }, "align": "left", "width": 100 } }, { "id": "field_M7yVYyeOec", "fieldType": "dimension", "processType": "", "dataType": "string", "originCode": "仓名称", "code": "仓名称", "originLabel": "仓名称", "label": "仓名称", "formula": null, "ext": {}, "props": { "sortable": true, "align": "left", "width": 100 } }, { "id": "field_HS3tIrUU3D", "fieldType": "dimension", "processType": "", "dataType": "string", "originCode": "仓code", "code": "仓code", "originLabel": "仓code", "label": "仓code", "formula": null, "ext": {}, "props": { "sortable": true, "align": "left", "width": 100 } }, { "id": "field_CsNnoSYt5m", "fieldType": "dimension", "processType": "", "dataType": "string", "originCode": "区域名称", "code": "区域名称", "originLabel": "区域名称", "label": "区域名称", "formula": null, "ext": {}, "props": { "sortable": true, "align": "left", "width": 100 } }, { "id": "field_TfgKWSMh7E", "fieldType": "dimension", "processType": "", "dataType": "string", "originCode": "商品状态", "code": "商品状态", "originLabel": "商品状态", "label": "商品状态", "formula": null, "ext": {}, "props": { "sortable": true, "align": "left", "width": 100 } }, { "id": "field_EjWJBgVed6", "fieldType": "dimension", "processType": "", "dataType": "string", "originCode": "商品id", "code": "商品id", "originLabel": "商品id", "label": "商品id", "formula": null, "ext": {}, "props": { "sortable": true, "align": "left", "width": 100 } }, { "id": "field_rA3PPjx7QM", "fieldType": "indicator", "processType": "", "dataType": "bigint", "originCode": "支付件数", "code": "支付件数-3dhxpxrvhppp", "originLabel": "支付件数", "label": "支付件数", "formula": { "aggregationType": "SUM" }, "ext": {}, "props": { "sortable": true, "valueFormatConfig": { "formatType": "number", "hasThousandths": true, "decimalDigits": 0 }, "align": "right", "width": 100 } }, { "id": "field_eTO1eWBFBf", "fieldType": "indicator", "processType": "", "dataType": "decimal", "originCode": "支付金额", "code": "支付金额-stdmdchy4q28", "originLabel": "支付金额", "label": "支付金额", "formula": { "aggregationType": "SUM" }, "ext": {}, "props": { "sortable": true, "valueFormatConfig": { "formatType": "number", "hasThousandths": true, "decimalDigits": 2 }, "align": "right", "width": 100 } }, { "id": "field_R34LBUT6dh", "fieldType": "indicator", "processType": "", "dataType": "bigint", "originCode": "支付用户数", "code": "支付用户数-zpnrb52liasj", "originLabel": "支付用户数", "label": "支付用户数", "formula": { "aggregationType": "SUM" }, "ext": {}, "props": { "sortable": true, "valueFormatConfig": { "formatType": "number", "hasThousandths": true, "decimalDigits": 0 }, "align": "right", "width": 100 } }, { "id": "field_wp3lUegaq7", "fieldType": "indicator", "processType": "", "dataType": "bigint", "originCode": "支付子订单数", "code": "支付子订单数-v0shth97lsmw", "originLabel": "支付子订单数", "label": "支付子订单数", "formula": { "aggregationType": "SUM" }, "ext": {}, "props": { "sortable": true, "valueFormatConfig": { "formatType": "number", "hasThousandths": true, "decimalDigits": 0 }, "align": "right", "width": 100 } } ] }, { "id": "Chart_YJCg8RRRZ5", "name": "明细表格[i4gu]", "componentName": "DeliciousChart_line", "componentType": "chart", "props": { "editExt": {}, "format": { "titleConfig": { "enable": true, "size": "medium", "showTotal": true }, "toolbarConfig": { "enable": true }, "globalConfig": { "forceFit": true, "fitHeight": true, "padding": [ 12, 12, 12, 12 ], "fitMode": "totalFit" }, "legendConfig": { "enable": true, "position": "top-left", "align": "center", "verticalAlign": "center" }, "tooltipConfig": { "enable": true, "showTitle": true, "width": 160 }, "annotation": {} } }, "dataSource": { "label": "测试", "code": "1341", "type": "dataset", "originType": "file", "originCode": "b20b28ad-9a31-4166-a663-27ffd626fc54", "isMultiDim": false, "isSelfAnalytic": true, "props": { "permissionType": [ 1, 2, 3 ], "applyPermissionItem": [], "allowApply": 1, "secretLevel": 2, "dataMaxZoneConfig": { "ptKey": "ds", "ptRange": 30 }, "dataDownloadByDataShare": { "switch": [ "true" ] }, "driverType": "hologresDriver", "originDatabaseName": "", "originTableName": "-" } }, "fields": [ { "id": "field_QejV1RmLUb", "fieldType": "dimension", "processType": "", "dataType": "date", "originCode": "日期", "code": "日期-5d4c1f", "originLabel": "日期", "label": "日期", "formula": { "timeType": "YYYY-MM-DD" }, "groupName": "row", "ext": {}, "props": { "sortable": true, "textFormatConfig": { "formatType": "date" }, "align": "left", "width": 100 } }, { "id": "field_rA3PPjx7QM", "fieldType": "indicator", "processType": "", "dataType": "bigint", "originCode": "支付件数", "code": "支付件数-3dhxpxrvhppp", "originLabel": "支付件数", "label": "支付件数", "formula": { "aggregationType": "SUM" }, "groupName": "y1", "ext": {}, "props": { "sortable": true, "valueFormatConfig": { "formatType": "number", "hasThousandths": true, "decimalDigits": 0 }, "align": "right", "width": 100 } }, { "id": "field_eTO1eWBFBf", "fieldType": "indicator", "processType": "", "dataType": "decimal", "originCode": "支付金额", "code": "支付金额-stdmdchy4q28", "originLabel": "支付金额", "label": "支付金额", "formula": { "aggregationType": "SUM" }, "groupName": "y1", "ext": {}, "props": { "sortable": true, "valueFormatConfig": { "formatType": "number", "hasThousandths": true, "decimalDigits": 2 }, "align": "right", "width": 100 } }, { "id": "field_R34LBUT6dh", "fieldType": "indicator", "processType": "", "dataType": "bigint", "originCode": "支付用户数", "code": "支付用户数-zpnrb52liasj", "originLabel": "支付用户数", "label": "支付用户数", "formula": { "aggregationType": "SUM" }, "groupName": "y1", "ext": {}, "props": { "sortable": true, "valueFormatConfig": { "formatType": "number", "hasThousandths": true, "decimalDigits": 0 }, "align": "right", "width": 100 } }, { "id": "field_QejV1RmLUb", "fieldType": "dimension", "processType": "", "dataType": "date", "originCode": "日期", "code": "日期-5d4c1f", "originLabel": "日期", "label": "日期", "formula": { "timeType": "YYYY-MM-DD" }, "groupName": "subdivision", "ext": {}, "props": { "sortable": true, "textFormatConfig": { "formatType": "date" }, "align": "left", "width": 100 } } ] }, { "id": "Chart_uxl22BaV39", "name": "明细表格[i4gu]", "componentName": "ProTable", "componentType": "chart", "props": { "editExt": {}, "format": { "titleConfig": { "enable": true, "size": "medium", "showTotal": true }, "toolbarConfig": { "enable": true }, "styleConfig": { "size": "medium", "ghost": false, "hasBorder": true, "isZebra": true }, "customSettingConfig": { "enable": true, "calcByCustomDims": true, "iconType": "show-text" }, "paginationConfig": { "enable": true, "defaultPageSize": 10, "type": "normal", "size": "medium", "hideOnlyOnePage": false }, "rowSelectionConfig": { "width": 50, "lock": true } } }, "dataSource": { "label": "测试", "code": "1341", "type": "dataset", "originType": "file", "originCode": "b20b28ad-9a31-4166-a663-27ffd626fc54", "isMultiDim": false, "isSelfAnalytic": true, "props": { "permissionType": [ 1, 2, 3 ], "applyPermissionItem": [], "allowApply": 1, "secretLevel": 2, "dataMaxZoneConfig": { "ptKey": "ds", "ptRange": 30 }, "dataDownloadByDataShare": { "switch": [ "true" ] }, "driverType": "hologresDriver", "originDatabaseName": "", "originTableName": "-" } }, "fields": [ { "id": "field_QejV1RmLUb", "fieldType": "dimension", "processType": "", "dataType": "date", "originCode": "日期", "code": "日期-5d4c1f", "originLabel": "日期", "label": "日期", "formula": { "timeType": "YYYY-MM-DD" }, "ext": {}, "props": { "sortable": true, "textFormatConfig": { "formatType": "date" }, "align": "left", "width": 100 } }, { "id": "field_M7yVYyeOec", "fieldType": "dimension", "processType": "", "dataType": "string", "originCode": "仓名称", "code": "仓名称", "originLabel": "仓名称", "label": "仓名称", "formula": null, "ext": {}, "props": { "sortable": true, "align": "left", "width": 100 } }, { "id": "field_HS3tIrUU3D", "fieldType": "dimension", "processType": "", "dataType": "string", "originCode": "仓code", "code": "仓code", "originLabel": "仓code", "label": "仓code", "formula": null, "ext": {}, "props": { "sortable": true, "align": "left", "width": 100 } }, { "id": "field_CsNnoSYt5m", "fieldType": "dimension", "processType": "", "dataType": "string", "originCode": "区域名称", "code": "区域名称", "originLabel": "区域名称", "label": "区域名称", "formula": null, "ext": {}, "props": { "sortable": true, "align": "left", "width": 100 } }, { "id": "field_TfgKWSMh7E", "fieldType": "dimension", "processType": "", "dataType": "string", "originCode": "商品状态", "code": "商品状态", "originLabel": "商品状态", "label": "商品状态", "formula": null, "ext": {}, "props": { "sortable": true, "align": "left", "width": 100 } }, { "id": "field_EjWJBgVed6", "fieldType": "dimension", "processType": "", "dataType": "string", "originCode": "商品id", "code": "商品id", "originLabel": "商品id", "label": "商品id", "formula": null, "ext": {}, "props": { "sortable": true, "align": "left", "width": 100 } }, { "id": "field_rA3PPjx7QM", "fieldType": "indicator", "processType": "", "dataType": "bigint", "originCode": "支付件数", "code": "支付件数-3dhxpxrvhppp", "originLabel": "支付件数", "label": "支付件数", "formula": { "aggregationType": "SUM" }, "ext": {}, "props": { "sortable": true, "valueFormatConfig": { "formatType": "number", "hasThousandths": true, "decimalDigits": 0 }, "align": "right", "width": 100 } }, { "id": "field_eTO1eWBFBf", "fieldType": "indicator", "processType": "", "dataType": "decimal", "originCode": "支付金额", "code": "支付金额-stdmdchy4q28", "originLabel": "支付金额", "label": "支付金额", "formula": { "aggregationType": "SUM" }, "ext": {}, "props": { "sortable": true, "valueFormatConfig": { "formatType": "number", "hasThousandths": true, "decimalDigits": 2 }, "align": "right", "width": 100 } }, { "id": "field_R34LBUT6dh", "fieldType": "indicator", "processType": "", "dataType": "bigint", "originCode": "支付用户数", "code": "支付用户数-zpnrb52liasj", "originLabel": "支付用户数", "label": "支付用户数", "formula": { "aggregationType": "SUM" }, "ext": {}, "props": { "sortable": true, "valueFormatConfig": { "formatType": "number", "hasThousandths": true, "decimalDigits": 0 }, "align": "right", "width": 100 } }, { "id": "field_wp3lUegaq7", "fieldType": "indicator", "processType": "", "dataType": "bigint", "originCode": "支付子订单数", "code": "支付子订单数-v0shth97lsmw", "originLabel": "支付子订单数", "label": "支付子订单数", "formula": { "aggregationType": "SUM" }, "ext": {}, "props": { "sortable": true, "valueFormatConfig": { "formatType": "number", "hasThousandths": true, "decimalDigits": 0 }, "align": "right", "width": 100 } } ] }, { "id": "Row_hwjmraFGTK", "name": "行布局", "componentName": "Row", "componentType": "container", "props": { "format": {} } }, { "id": "Chart_1kgue2Tk4j", "name": "明细表格[i4gu]", "componentName": "Card_common_indicator", "componentType": "chart", "props": { "editExt": {}, "format": { "titleConfig": { "enable": true, "size": "medium", "showTotal": true }, "styleConfig": { "cardStyleType": "radiusBorder", "showSlider": false, "widthType": "" }, "toolbarConfig": { "enable": true } } }, "dataSource": { "label": "测试", "code": "1341", "type": "dataset", "originType": "file", "originCode": "b20b28ad-9a31-4166-a663-27ffd626fc54", "isMultiDim": false, "isSelfAnalytic": true, "props": { "permissionType": [ 1, 2, 3 ], "applyPermissionItem": [], "allowApply": 1, "secretLevel": 2, "dataMaxZoneConfig": { "ptKey": "ds", "ptRange": 30 }, "dataDownloadByDataShare": { "switch": [ "true" ] }, "driverType": "hologresDriver", "originDatabaseName": "", "originTableName": "-" } }, "fields": [ { "id": "field_rA3PPjx7QM", "fieldType": "indicator", "processType": "", "dataType": "bigint", "originCode": "支付件数", "code": "支付件数-3dhxpxrvhppp", "originLabel": "支付件数", "label": "支付件数", "formula": { "aggregationType": "SUM" }, "groupName": "Main", "ext": {}, "props": { "sortable": true, "valueFormatConfig": { "formatType": "number", "hasThousandths": true, "decimalDigits": 0 }, "align": "right", "width": 100 }, "groupIndex": 0 }, { "id": "field_eTO1eWBFBf", "fieldType": "indicator", "processType": "", "dataType": "decimal", "originCode": "支付金额", "code": "支付金额-stdmdchy4q28", "originLabel": "支付金额", "label": "支付金额", "formula": { "aggregationType": "SUM" }, "groupName": "Main", "ext": {}, "props": { "sortable": true, "valueFormatConfig": { "formatType": "number", "hasThousandths": true, "decimalDigits": 2 }, "align": "right", "width": 100 }, "groupIndex": 1 }, { "id": "field_R34LBUT6dh", "fieldType": "indicator", "processType": "", "dataType": "bigint", "originCode": "支付用户数", "code": "支付用户数-zpnrb52liasj", "originLabel": "支付用户数", "label": "支付用户数", "formula": { "aggregationType": "SUM" }, "groupName": "Main", "ext": {}, "props": { "sortable": true, "valueFormatConfig": { "formatType": "number", "hasThousandths": true, "decimalDigits": 0 }, "align": "right", "width": 100 }, "groupIndex": 2 } ] } ], "layout": { "_root": [ { "id": "root", "height": 0, "width": 24 } ], "root": [ { "id": "Chart_1kgue2Tk4j", "height": 172, "width": 24 }, { "id": "Row_hwjmraFGTK", "width": 24, "height": 511, "container": "Row" }, { "id": "Chart_YJCg8RRRZ5", "height": 352, "width": 24 } ], "Row_hwjmraFGTK": [ { "id": "Chart_e5fwOQi4gu", "height": 511, "width": 12 }, { "id": "Chart_uxl22BaV39", "height": 511, "width": 12 } ] }, "linkages": [], "filters": [], "options": {}, "setting": {}, "datasetDict": {} }, "setting": {} }, "loadModule": { "engines": { "ascp-visual/sailing": [ "1.0.3", "1.0.4" ] }, "bundles": {}, "theme": { "ascp-design/ascp-design": [ "7.0.3", "7.0.3" ] }, "customBundles": {} } } var myCopy = null;
Tests:
Lodash cloneDeep
myCopy = _.cloneDeep(MyObject);
Native structuredClone
myCopy = structuredClone(MyObject);
JSON Parse
myCopy = JSON.parse(JSON.stringify(MyObject));
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Lodash cloneDeep
Native structuredClone
JSON Parse
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 years ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:120.0) Gecko/20100101 Firefox/120.0
Browser/OS:
Firefox 120 on Mac OS X 10.15
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Lodash cloneDeep
6936.7 Ops/sec
Native structuredClone
14668.1 Ops/sec
JSON Parse
19941.2 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
A complex benchmarking scenario! After analyzing the data, I'll attempt to provide an answer. **Individual test cases:** 1. **"Benchmark Definition": "myCopy = _.cloneDeep(MyObject);",** * **Test Name:** "Lodash cloneDeep" 2. **"Benchmark Definition": "myCopy = structuredClone(MyObject);,"** * **Test Name:** "Native structuredClone" 3. **"Benchmark Definition": "myCopy = JSON.parse(JSON.stringify(MyObject));",** * **Test Name:** "JSON Parse" **Latest benchmark result:** 1. **RawUAString**: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:120.0) Gecko/20100101 Firefox/120.0" 2. **Browser**: "Firefox 120" 3. **DevicePlatform**: "Desktop" 4. **OperatingSystem**: "Mac OS X 10.15" 5. **ExecutionsPerSecond**: * **TestName:** "JSON Parse" = 14668.0556640625 * **TestName:** "Native structuredClone" = 6936.74462890625 * **TestName:** "Lodash cloneDeep" = 19941.205078125 **Observations:** * The latest benchmark result shows that: + Lodash `cloneDeep` is the fastest, with an execution rate of approximately 20 executions per second. + Native `structuredClone` is slower than expected, but still faster than JSON Parse. + JSON Parse is the slowest. **Conclusion:** Lodash's `cloneDeep` is currently the fastest method for cloning a complex object like `MyObject`. However, it's worth noting that the results may vary depending on the specific use case and environment.
Related benchmarks:
Lodash cloneDeep vs structuredClone vs node-clone no circular check, cloning of configs
Lodash cloneDeep vs structuredClone vs JSON-JSON
Lodash cloneDeep vs structuredClone vs JSON.parse clone vs RFDC 322KB input
Lodash cloneDeep vs structuredClone vs JSON Parse (Big Object)
Comments
Confirm delete:
Do you really want to delete benchmark?