Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
structuredClone vs deepClone in large objects
(version: 1)
This benchmark creates huge objects to be cloned by lodash's cloneDeep function vs the native structuredClone
Comparing performance of:
cloneDeep vs structuredClone
Created:
one year ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js"></script>
Script Preparation code:
function createComplexNestedObject(depth = 10, breadth = 5, level = 1) { const result = {}; if (level < depth) result[`deepStart_${level}`] = createComplexNestedObject(depth, breadth, level + 1); for (let index = 0; index < breadth; index++) { const opts = [ `val_${level}_${index}_` + 'x'.repeat(50) /* string */, level * 1e3 + index /* number */, index % 2 === 0 /* boolean */, null /* null */, [index, level, `s${index}`] /* array */, new Date(Date.UTC(2020 + level, index % 12, (index % 28) + 1)) /* date */, new RegExp(`p_${level}_${index}`) /* regexp */ ]; result[`field_${level}_${index}`] = opts[index % opts.length]; if (level < depth && index === Math.floor(breadth / 2)) result[`deepMid_${level}`] = createComplexNestedObject(depth, breadth, level + 1); } if (level < depth) result[`deepEnd_${level}`] = createComplexNestedObject(depth, breadth, level + 1); return result; } var MyObject = createComplexNestedObject(10, 8); var myCopy = null;
Tests:
cloneDeep
myCopy = _.cloneDeep(MyObject)
structuredClone
myCopy = structuredClone(MyObject);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
cloneDeep
structuredClone
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
13 days ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36
Browser/OS:
Chrome 147 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
cloneDeep
14.7 Ops/sec
structuredClone
27.5 Ops/sec
Related benchmarks:
Lodash cloneDeep vs for loop vs JSON parse vs recursive clone deep vs recursive reduce clone deep
Object Deep Copy with deep clone
123132
Lodash cloneDeep vs freeze vs monokee deepClone
Deep Clone vs JSON.Stringify
Lodash cloneDeep vs structuredClone vs node-clone, cloning of typedarrays
LargeObject Lodash cloneDeep vs structuredClone vs JSON Parse
Deep Clone vs JSON.Stringify vs structuredClone
Clone objects
Comments
Confirm delete:
Do you really want to delete benchmark?