Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash: clone vs cloneDeep vs JSON
(version: 0)
Comparing performance of:
clone vs cloneDeep vs JSON
Created:
7 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src='https://cdn.jsdelivr.net/npm/lodash@4.17.11/lodash.min.js'></script>
Tests:
clone
let a, b a = [ '{{repeat(5, 7)}}', { _id: '{{objectId()}}', index: '{{index()}}', guid: '{{guid()}}', isActive: '{{bool()}}', balance: '{{floating(1000, 4000, 2, "$0,0.00")}}', picture: 'http://placehold.it/32x32', age: '{{integer(20, 40)}}', eyeColor: '{{random("blue", "brown", "green")}}', name: '{{firstName()}} {{surname()}}', gender: '{{gender()}}', company: '{{company().toUpperCase()}}', email: '{{email()}}', phone: '+1 {{phone()}}', address: '{{integer(100, 999)}} {{street()}}, {{city()}}, {{state()}}, {{integer(100, 10000)}}', about: '{{lorem(1, "paragraphs")}}', registered: '{{date(new Date(2014, 0, 1), new Date(), "YYYY-MM-ddThh:mm:ss Z")}}', latitude: '{{floating(-90.000001, 90)}}', longitude: '{{floating(-180.000001, 180)}}', tags: [ '{{repeat(7)}}', '{{lorem(1, "words")}}' ], friends: [ '{{repeat(3)}}', { id: '{{index()}}', name: '{{firstName()}} {{surname()}}' } ], greeting: function (tags) { return 'Hello, ' + this.name + '! You have ' + tags.integer(1, 10) + ' unread messages.'; }, favoriteFruit: function (tags) { var fruits = ['apple', 'banana', 'strawberry']; return fruits[tags.integer(0, fruits.length - 1)]; } } ] b = _.clone(a)
cloneDeep
let a, b a = [ '{{repeat(5, 7)}}', { _id: '{{objectId()}}', index: '{{index()}}', guid: '{{guid()}}', isActive: '{{bool()}}', balance: '{{floating(1000, 4000, 2, "$0,0.00")}}', picture: 'http://placehold.it/32x32', age: '{{integer(20, 40)}}', eyeColor: '{{random("blue", "brown", "green")}}', name: '{{firstName()}} {{surname()}}', gender: '{{gender()}}', company: '{{company().toUpperCase()}}', email: '{{email()}}', phone: '+1 {{phone()}}', address: '{{integer(100, 999)}} {{street()}}, {{city()}}, {{state()}}, {{integer(100, 10000)}}', about: '{{lorem(1, "paragraphs")}}', registered: '{{date(new Date(2014, 0, 1), new Date(), "YYYY-MM-ddThh:mm:ss Z")}}', latitude: '{{floating(-90.000001, 90)}}', longitude: '{{floating(-180.000001, 180)}}', tags: [ '{{repeat(7)}}', '{{lorem(1, "words")}}' ], friends: [ '{{repeat(3)}}', { id: '{{index()}}', name: '{{firstName()}} {{surname()}}' } ], greeting: function (tags) { return 'Hello, ' + this.name + '! You have ' + tags.integer(1, 10) + ' unread messages.'; }, favoriteFruit: function (tags) { var fruits = ['apple', 'banana', 'strawberry']; return fruits[tags.integer(0, fruits.length - 1)]; } } ] b = _.cloneDeep(a)
JSON
let a, b a = [ '{{repeat(5, 7)}}', { _id: '{{objectId()}}', index: '{{index()}}', guid: '{{guid()}}', isActive: '{{bool()}}', balance: '{{floating(1000, 4000, 2, "$0,0.00")}}', picture: 'http://placehold.it/32x32', age: '{{integer(20, 40)}}', eyeColor: '{{random("blue", "brown", "green")}}', name: '{{firstName()}} {{surname()}}', gender: '{{gender()}}', company: '{{company().toUpperCase()}}', email: '{{email()}}', phone: '+1 {{phone()}}', address: '{{integer(100, 999)}} {{street()}}, {{city()}}, {{state()}}, {{integer(100, 10000)}}', about: '{{lorem(1, "paragraphs")}}', registered: '{{date(new Date(2014, 0, 1), new Date(), "YYYY-MM-ddThh:mm:ss Z")}}', latitude: '{{floating(-90.000001, 90)}}', longitude: '{{floating(-180.000001, 180)}}', tags: [ '{{repeat(7)}}', '{{lorem(1, "words")}}' ], friends: [ '{{repeat(3)}}', { id: '{{index()}}', name: '{{firstName()}} {{surname()}}' } ], greeting: function (tags) { return 'Hello, ' + this.name + '! You have ' + tags.integer(1, 10) + ' unread messages.'; }, favoriteFruit: function (tags) { var fruits = ['apple', 'banana', 'strawberry']; return fruits[tags.integer(0, fruits.length - 1)]; } } ] b = JSON.parse(JSON.stringify(a))
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
clone
cloneDeep
JSON
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):
I'll do my best to provide a concise answer. It appears that the benchmark results are for three tests: `clone`, `cloneDeep`, and `JSON`. The results show the number of executions per second (in executions/sec) for each test on a Mac OS X 10.14.0 machine with Chrome 71 browser. Here's a brief summary: * `clone`: 2,606,396 executions/sec * `cloneDeep`: 112,610 executions/sec * `JSON`: 90,514 executions/sec These results suggest that the `clone` function is significantly faster than the `cloneDeep` and `JSON.parse(JSON.stringify(a))` functions. However, without more context or information about what these functions are doing, it's difficult to provide a more detailed analysis. If you'd like me to explain the differences between these tests or provide further insights, please let me know!
Related benchmarks:
Lodash deep clone vs JSON.stringfy
Lodash cloneDeep vs JSON Clone with Array
lodash cloneDeep vs json.stringify
Object Clone Lodash vs structuredClone
Object cloning with Lodash clone vs cloneDeep vs merge vs structuredClone vs JSON.parse(JSON.stringify(o))
Comments
Confirm delete:
Do you really want to delete benchmark?