Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Deep Copy (20230730)
(version: 0)
Comparing performance of:
JSON function vs Recursive function vs lodash
Created:
2 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.10/lodash.js"></script> <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
Script Preparation code:
function recursiveDeepCopy(obj) { if (typeof(obj) !== 'object' || !obj) return obj; if (obj instanceof Date) return new Date(obj.getTime()); if (obj instanceof Array) { return obj.reduce((arr, item, i) => { arr[i] = recursiveDeepCopy(item); return arr; }, []); } if (obj instanceof Object) { return Object.keys(obj).reduce((newObj, key) => { newObj[key] = recursiveDeepCopy(obj[key]); return newObj; }, {}); } } function jsonDeepCopy(o) { return JSON.parse(JSON.stringify(o)); } var dimensions = [{ "dimensions": [{ "runtime": { "common": { "client": null, "server": null } } }, { "device": { "android": null, "blackberry": null, "iemobile": null, "iphone": null, "ipad": null, "kindle": null, "opera-mini": null, "palm": null } }, { "environment": { "development": { "dev": null, "test": null }, "production": { "stage": null, "prod": null } } }, { "lang": { "ar": { "ar-JO": null, "ar-MA": null, "ar-SA": null, "ar-EG": null }, "bn": { "bn-IN": null }, "ca": { "ca-ES": null }, "cs": { "cs-CZ": null }, "da": { "da-DK": null }, "de": { "de-AT": null, "de-DE": null }, "el": { "el-GR": null }, "en": { "en-AU": null, "en-BG": null, "en-CA": null, "en-GB": null, "en-GY": null, "en-HK": null, "en-IE": null, "en-IN": null, "en-MY": null, "en-NZ": null, "en-PH": null, "en-SG": null, "en-US": null, "en-ZA": null }, "es": { "es-AR": null, "es-BO": null, "es-CL": null, "es-CO": null, "es-EC": null, "es-ES": null, "es-MX": null, "es-PE": null, "es-PY": null, "es-US": null, "es-UY": null, "es-VE": null }, "fi": { "fi-FI": null }, "fr": { "fr-BE": null, "fr-CA": null, "fr-FR": null, "fr-GF": null }, "hi": { "hi-IN": null }, "hu": { "hu-HU": null }, "id": { "id-ID": null }, "it": { "it-IT": null }, "ja": { "ja-JP": null }, "kn": { "kn-IN": null }, "ko": { "ko-KR": null }, "ml": { "ml-IN": null }, "mr": { "mr-IN": null }, "ms": { "ms-MY": null }, "nb": { "nb-NO": null }, "nl": { "nl-BE": null, "nl-NL": null, "nl-SR": null }, "pl": { "pl-PL": null }, "pt": { "pt-BR": null }, "ro": { "ro-RO": null }, "ru": { "ru-RU": null }, "sv": { "sv-SE": null }, "ta": { "ta-IN": null }, "te": { "te-IN": null }, "th": { "th-TH": null }, "tr": { "tr-TR": null }, "vi": { "vi-VN": null }, "zh": { "zh-Hans": { "zh-Hans-CN": null }, "zh-Hant": { "zh-Hant-HK": null, "zh-Hant-TW": null } } } }] }]
Tests:
JSON function
var dimensionsCopy = jsonDeepCopy(dimensions);
Recursive function
var dimensionsCopy = recursiveDeepCopy(dimensions);
lodash
var dimensionsCopy = _.cloneDeep(dimensions);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
JSON function
Recursive function
lodash
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 appears that the text is a JSON object containing benchmarking data, likely from a testing framework such as Jest or Cypress. The data includes: 1. A `jsonDeepCopy` function's execution time and performance metrics for each individual test case. 2. Three separate test cases: * "JSON function" with execution time: 42128.39 executions per second * "lodash" with execution time: 26946.41 executions per second * "Recursive function" with execution time: 17544.63 executions per second 3. A `Html Preparation Code` section that includes script tags for loading external JavaScript libraries. 4. An `Individual test cases` section that lists three test cases, each with a `Benchmark Definition`, `Test Name`, and no performance metrics. The latest benchmark result is provided in the format of an array of objects, where each object contains information about a single test case, including its execution time and performance metrics. If you would like to extract specific data from this JSON object, I can help with that.
Related benchmarks:
Object Deep Copy
Deep Clone #2
Object Deep Copy (+customs)
Object Deep Copy 2
Compare deep copy of object
Comments
Confirm delete:
Do you really want to delete benchmark?