Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
structuredClone vs deepClone in large objects
This benchmark creates huge objects to be cloned by lodash's cloneDeep function vs the native structuredClone
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36
Browser:
Chrome 139
Operating system:
Linux
Device Platform:
Desktop
Date tested:
8 months ago
Test name
Executions per second
cloneDeep
17.8 Ops/sec
structuredClone
34.0 Ops/sec
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);