Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Test different ways of cloning objects
https://developer.mozilla.org/en-US/docs/Web/API/structuredClone
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36
Browser:
Chrome 132
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Lodash cloneDeep
20946.1 Ops/sec
Native structuredClone
36142.1 Ops/sec
Json Clone
82785.2 Ops/sec
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js'></script> <script src="https://cdn.jsdelivr.net/npm/clone-deep@4.0.1/index.min.js"></script>
Script Preparation code:
const original = [ { "id": " Sync ", "title": " Sync ", "attendees": [ "Raph", "Thomas", "Amy", "Richard", "Debra", "Kevin" ], "flexible": false, "start": "2023-12-08T16:00:00.000Z", "end": "2023-12-08T16:30:00.000Z" }, { "id": " Sync ", "title": " Sync ", "attendees": [ "Raph", "Thomas", "Amy", "Richard", "Debra", "Kevin" ], "flexible": false, "start": "2023-12-08T16:00:00.000Z", "end": "2023-12-08T16:30:00.000Z" }, { "id": " Sync ", "title": " Sync ", "attendees": [ "Raph", "Thomas", "Amy", "Richard", "Debra", "Kevin" ], "flexible": false, "start": "2023-12-08T16:00:00.000Z", "end": "2023-12-08T16:30:00.000Z" }, { "id": " Sync ", "title": " Sync ", "attendees": [ "Raph", "Thomas", "Amy", "Richard", "Debra", "Kevin" ], "flexible": false, "start": "2023-12-08T16:00:00.000Z", "end": "2023-12-08T16:30:00.000Z" }, { "id": " Sync ", "title": " Sync ", "attendees": [ "Raph", "Thomas", "Amy", "Richard", "Debra", "Kevin" ], "flexible": false, "start": "2023-12-08T16:00:00.000Z", "end": "2023-12-08T16:30:00.000Z" }, { "id": " Sync ", "title": " Sync ", "attendees": [ "Raph", "Thomas", "Amy", "Richard", "Debra", "Kevin" ], "flexible": false, "start": "2023-12-08T16:00:00.000Z", "end": "2023-12-08T16:30:00.000Z" }, { "id": " Sync ", "title": " Sync ", "attendees": [ "Raph", "Thomas", "Amy", "Richard", "Debra", "Kevin" ], "flexible": false, "start": "2023-12-08T16:00:00.000Z", "end": "2023-12-08T16:30:00.000Z" }, { "id": " Sync ", "title": " Sync ", "attendees": [ "Raph", "Thomas", "Amy", "Richard", "Debra", "Kevin" ], "flexible": false, "start": "2023-12-08T16:00:00.000Z", "end": "2023-12-08T16:30:00.000Z" }, { "id": " Sync ", "title": " Sync ", "attendees": [ "Raph", "Thomas", "Amy", "Richard", "Debra", "Kevin" ], "flexible": false, "start": "2023-12-08T16:00:00.000Z", "end": "2023-12-08T16:30:00.000Z" }, { "id": " Sync ", "title": " Sync ", "attendees": [ "Raph", "Thomas", "Amy", "Richard", "Debra", "Kevin" ], "flexible": false, "start": "2023-12-08T16:00:00.000Z", "end": "2023-12-08T16:30:00.000Z" }, { "id": " Sync ", "title": " Sync ", "attendees": [ "Raph", "Thomas", "Amy", "Richard", "Debra", "Kevin" ], "flexible": false, "start": "2023-12-08T16:00:00.000Z", "end": "2023-12-08T16:30:00.000Z" }, { "id": " Sync ", "title": " Sync ", "attendees": [ "Raph", "Thomas", "Amy", "Richard", "Debra", "Kevin" ], "flexible": false, "start": "2023-12-08T16:00:00.000Z", "end": "2023-12-08T16:30:00.000Z" }, { "id": " Sync ", "title": " Sync ", "attendees": [ "Raph", "Thomas", "Amy", "Richard", "Debra", "Kevin" ], "flexible": false, "start": "2023-12-08T16:00:00.000Z", "end": "2023-12-08T16:30:00.000Z" }, { "id": " Sync ", "title": " Sync ", "attendees": [ "Raph", "Thomas", "Amy", "Richard", "Debra", "Kevin" ], "flexible": false, "start": "2023-12-08T16:00:00.000Z", "end": "2023-12-08T16:30:00.000Z" }, { "id": " Sync ", "title": " Sync ", "attendees": [ "Raph", "Thomas", "Amy", "Richard", "Debra", "Kevin" ], "flexible": false, "start": "2023-12-08T16:00:00.000Z", "end": "2023-12-08T16:30:00.000Z" }, { "id": " Sync ", "title": " Sync ", "attendees": [ "Raph", "Thomas", "Amy", "Richard", "Debra", "Kevin" ], "flexible": false, "start": "2023-12-08T16:00:00.000Z", "end": "2023-12-08T16:30:00.000Z" }, { "id": " Sync ", "title": " Sync ", "attendees": [ "Raph", "Thomas", "Amy", "Richard", "Debra", "Kevin" ], "flexible": false, "start": "2023-12-08T16:00:00.000Z", "end": "2023-12-08T16:30:00.000Z" }, { "id": " Sync ", "title": " Sync ", "attendees": [ "Raph", "Thomas", "Amy", "Richard", "Debra", "Kevin" ], "flexible": false, "start": "2023-12-08T16:00:00.000Z", "end": "2023-12-08T16:30:00.000Z" }, { "id": " Sync ", "title": " Sync ", "attendees": [ "Raph", "Thomas", "Amy", "Richard", "Debra", "Kevin" ], "flexible": false, "start": "2023-12-08T16:00:00.000Z", "end": "2023-12-08T16:30:00.000Z" }, { "id": " Sync ", "title": " Sync ", "attendees": [ "Raph", "Thomas", "Amy", "Richard", "Debra", "Kevin" ], "flexible": false, "start": "2023-12-08T16:00:00.000Z", "end": "2023-12-08T16:30:00.000Z" }, { "id": " Sync ", "title": " Sync ", "attendees": [ "Raph", "Thomas", "Amy", "Richard", "Debra", "Kevin" ], "flexible": false, "start": "2023-12-08T16:00:00.000Z", "end": "2023-12-08T16:30:00.000Z" }, { "id": " Sync ", "title": " Sync ", "attendees": [ "Raph", "Thomas", "Amy", "Richard", "Debra", "Kevin" ], "flexible": false, "start": "2023-12-08T16:00:00.000Z", "end": "2023-12-08T16:30:00.000Z" }, { "id": " Sync ", "title": " Sync ", "attendees": [ "Raph", "Thomas", "Amy", "Richard", "Debra", "Kevin" ], "flexible": false, "start": "2023-12-08T16:00:00.000Z", "end": "2023-12-08T16:30:00.000Z" } ] 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:
Lodash cloneDeep
myCopy = _.cloneDeep(original);
Native structuredClone
myCopy = structuredClone(original);
Json Clone
myCopy = JSON.parse(JSON.stringify(original));
recursiveDeepCopy
myCopy = recursiveDeepCopy(original);