Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
me vs the ecosystem
(version: 0)
just benchmarking things
Comparing performance of:
Lodash cloneDeep vs Json clone vs Ramda clone vs hand rolled vs loop not map (still recursive) vs original gangster vs moar hand (un)rolling vs roll it back up bruh
Created:
6 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.25.0/ramda.min.js"></script>
Script Preparation code:
var MyObject = [ { "_id": "5e1e19a37db52f9e9d93e658", "index": 0, "guid": "396e60ae-845d-4503-b494-2a0ccd1df9f2", "isActive": false, "balance": "$1,389.79", "picture": "http://placehold.it/32x32", "age": 26, "eyeColor": "green", "name": "Josie Head", "gender": "female", "company": "FITCORE", "email": "josiehead@fitcore.com", "phone": "+1 (960) 535-2795", "address": "846 Regent Place, Twilight, Missouri, 5131", "about": "Duis adipisicing commodo reprehenderit veniam cillum nostrud sit sunt est. Tempor laborum pariatur irure nulla ex reprehenderit. Voluptate anim eu et nostrud ipsum mollit aute qui ea ullamco. Nulla minim sint voluptate exercitation nostrud mollit eu mollit. Ea duis dolor quis enim consectetur. Veniam cillum exercitation incididunt reprehenderit.\r\n", "registered": "2019-01-06T08:54:40 +05:00", "latitude": -80.487714, "longitude": 78.798071, "tags": [ "minim", "irure", "dolor", "commodo", "magna", "excepteur", "magna" ], "friends": [ { "id": 0, "name": "Odom Grant" }, { "id": 1, "name": "Hester Caldwell" }, { "id": 2, "name": "Clements Bullock" } ], "greeting": "Hello, Josie Head! You have 3 unread messages.", "favoriteFruit": "apple" }, { "_id": "5e1e19a38ad96c2c356f4bfb", "index": 1, "guid": "4786ea00-8742-439f-8e2a-004a2bae8a84", "isActive": true, "balance": "$2,048.19", "picture": "http://placehold.it/32x32", "age": 26, "eyeColor": "blue", "name": "Julie Kemp", "gender": "female", "company": "FUELWORKS", "email": "juliekemp@fuelworks.com", "phone": "+1 (886) 498-3935", "address": "152 Middleton Street, Celeryville, Ohio, 9868", "about": "Dolore eu do laborum irure amet nulla deserunt sunt ex et voluptate aute reprehenderit irure. Ullamco tempor aute sunt dolore nulla consequat esse est occaecat sunt non. Reprehenderit esse aute Lorem aliquip elit fugiat incididunt mollit sint qui dolore incididunt mollit. Aliquip ad mollit anim proident ipsum irure. Elit ullamco est eu sunt nostrud aliquip laboris sint reprehenderit. Aliquip anim eiusmod officia duis dolor voluptate duis nisi.\r\n", "registered": "2018-08-12T10:46:50 +04:00", "latitude": -3.524966, "longitude": -156.077579, "tags": [ "minim", "est", "Lorem", "nostrud", "enim", "non", "ea" ], "friends": [ { "id": 0, "name": "Barr Scott" }, { "id": 1, "name": "Atkinson Avery" }, { "id": 2, "name": "Teri Rivera" } ], "greeting": "Hello, Julie Kemp! You have 6 unread messages.", "favoriteFruit": "apple" }, { "_id": "5e1e19a343953743072e48c9", "index": 2, "guid": "f0b3b8a2-6383-4cfa-a95e-439d3e360592", "isActive": true, "balance": "$1,305.41", "picture": "http://placehold.it/32x32", "age": 34, "eyeColor": "green", "name": "Herman Griffith", "gender": "male", "company": "OPTICOM", "email": "hermangriffith@opticom.com", "phone": "+1 (922) 507-3579", "address": "314 Dekalb Avenue, Dixie, Minnesota, 2312", "about": "Anim mollit esse adipisicing et consectetur proident. Ut minim tempor consectetur aute eiusmod eu. Aliquip do esse pariatur aliqua non cillum. Magna sint laboris reprehenderit duis et id eu velit.\r\n", "registered": "2018-06-12T09:35:46 +04:00", "latitude": -30.773629, "longitude": -47.060717, "tags": [ "aute", "pariatur", "deserunt", "et", "cillum", "id", "excepteur" ], "friends": [ { "id": 0, "name": "Mack David" }, { "id": 1, "name": "Joanne Bryan" }, { "id": 2, "name": "Carroll Allen" } ], "greeting": "Hello, Herman Griffith! You have 6 unread messages.", "favoriteFruit": "apple" }, { "_id": "5e1e19a344109f0176249156", "index": 3, "guid": "8d123a89-ac66-40ee-9d1d-3e34d12a66c5", "isActive": true, "balance": "$1,877.60", "picture": "http://placehold.it/32x32", "age": 22, "eyeColor": "blue", "name": "Best Bruce", "gender": "male", "company": "MAINELAND", "email": "bestbruce@maineland.com", "phone": "+1 (835) 553-3427", "address": "247 Cumberland Street, Volta, Rhode Island, 6571", "about": "Fugiat velit id veniam ut culpa aliqua dolore excepteur fugiat fugiat Lorem irure. Consectetur anim pariatur eu irure et. Elit anim voluptate magna ut minim labore. Occaecat qui pariatur ea quis Lorem consectetur aute labore aliqua ut aute irure sunt. Tempor eu pariatur sint excepteur exercitation aliqua aliquip proident deserunt. Incididunt dolore proident est ex ipsum.\r\n", "registered": "2016-09-03T02:40:47 +04:00", "latitude": -86.651356, "longitude": -72.364284, "tags": [ "exercitation", "dolor", "duis", "tempor", "ea", "ut", "enim" ], "friends": [ { "id": 0, "name": "Bolton Peters" }, { "id": 1, "name": "Lucinda Franklin" }, { "id": 2, "name": "Humphrey Gentry" } ], "greeting": "Hello, Best Bruce! You have 4 unread messages.", "favoriteFruit": "strawberry" }, { "_id": "5e1e19a3ebc39ce616e60e71", "index": 4, "guid": "c97a8bf9-f1d5-4d3a-9a82-1470ddb80863", "isActive": true, "balance": "$2,794.32", "picture": "http://placehold.it/32x32", "age": 21, "eyeColor": "green", "name": "Young Frederick", "gender": "female", "company": "MATRIXITY", "email": "youngfrederick@matrixity.com", "phone": "+1 (899) 577-2643", "address": "405 Bay Street, Harold, New York, 2507", "about": "Ea labore dolor est pariatur consectetur aute qui cillum voluptate. Lorem voluptate mollit consectetur in elit reprehenderit. In elit magna Lorem dolore nostrud ut in ad pariatur id. Nisi eiusmod pariatur ut labore. Anim elit do excepteur ex mollit ad labore excepteur aliquip. Ipsum cillum mollit aute ad elit esse esse et eu anim veniam.\r\n", "registered": "2017-04-26T12:04:12 +04:00", "latitude": -6.274446, "longitude": -177.658413, "tags": [ "sit", "sunt", "pariatur", "commodo", "adipisicing", "non", "enim" ], "friends": [ { "id": 0, "name": "Latasha Mclean" }, { "id": 1, "name": "Dillard Barrera" }, { "id": 2, "name": "Roth Acevedo" } ], "greeting": "Hello, Young Frederick! You have 5 unread messages.", "favoriteFruit": "strawberry" }, { "_id": "5e1e19a3f36e5a3ff58c3f1e", "index": 5, "guid": "2c41264a-f19e-4fa5-91d7-ca8cf5314b0a", "isActive": true, "balance": "$2,323.64", "picture": "http://placehold.it/32x32", "age": 22, "eyeColor": "blue", "name": "Cotton Warner", "gender": "male", "company": "EQUITAX", "email": "cottonwarner@equitax.com", "phone": "+1 (871) 439-2340", "address": "517 Madoc Avenue, Chloride, Utah, 9942", "about": "Aute esse adipisicing fugiat sunt. Ullamco est officia ex quis fugiat nostrud Lorem consectetur minim aliqua incididunt tempor dolore. Anim duis consectetur commodo Lorem proident id elit reprehenderit velit mollit aute non elit est. Tempor do occaecat officia est fugiat qui laborum ad do magna.\r\n", "registered": "2018-10-20T10:42:15 +04:00", "latitude": 47.224342, "longitude": 84.61698, "tags": [ "mollit", "fugiat", "sint", "nisi", "sit", "aliquip", "deserunt" ], "friends": [ { "id": 0, "name": "Jodi Long" }, { "id": 1, "name": "Jenifer Willis" }, { "id": 2, "name": "Kirsten Roberts" } ], "greeting": "Hello, Cotton Warner! You have 6 unread messages.", "favoriteFruit": "banana" }, { "_id": "5e1e19a358fd18301abe8d8d", "index": 6, "guid": "8a590918-c40e-4291-8e16-5919c01ce395", "isActive": false, "balance": "$1,809.92", "picture": "http://placehold.it/32x32", "age": 33, "eyeColor": "green", "name": "Margo Nash", "gender": "female", "company": "FROLIX", "email": "margonash@frolix.com", "phone": "+1 (889) 407-3670", "address": "916 Colonial Road, Belfair, Connecticut, 1956", "about": "Amet ullamco aliqua occaecat nulla laborum incididunt minim nostrud sint. Eiusmod ut labore adipisicing commodo consectetur. Id cupidatat proident officia do. Aute nostrud sit pariatur irure consequat esse enim magna nisi. Magna ad cupidatat cupidatat amet nisi incididunt quis enim in aliquip ut velit sint aliquip.\r\n", "registered": "2015-06-08T03:26:01 +04:00", "latitude": -69.241111, "longitude": -40.43834, "tags": [ "ullamco", "commodo", "deserunt", "sint", "consectetur", "pariatur", "ullamco" ], "friends": [ { "id": 0, "name": "Malinda Lang" }, { "id": 1, "name": "Jeanie Rivers" }, { "id": 2, "name": "Greene Wilkerson" } ], "greeting": "Hello, Margo Nash! You have 6 unread messages.", "favoriteFruit": "banana" } ]; var myCopy = null;
Tests:
Lodash cloneDeep
myCopy = _.cloneDeep(MyObject);
Json clone
myCopy = JSON.parse(JSON.stringify(MyObject));
Ramda clone
myCopy = R.clone(MyObject);
hand rolled
const cp=(obj)=>"object" === typeof obj ? Object.fromEntries(Object.entries(obj).map(([k,v])=>[k,cp(v)])) : obj myCopy = cp(MyObject)
loop not map (still recursive)
const cp_old=(obj)=>{ if ("object" !== typeof obj) { return obj } else { const entries = Object.entries(obj) for(let i = 0; i < entries.length; i++) { entries[i][1] = cp_old(entries[i][1]) } return Object.fromEntries(entries) } } myCopy = cp_old(MyObject)
original gangster
const cp_stack=(obj)=>{ if ("object" !== typeof obj) { return obj } else { const stack = [] let entries = Object.entries(obj) let i=0 stackloop: while(true) { for(; i < entries.length; i++) { if ("object" !== typeof entries[i][1]) continue stack.push([i,entries]) entries = Object.entries(entries[i][1]) i = 0 continue stackloop } if (stack.length === 0) break const copy = Object.fromEntries(entries) ;[i, entries] = stack.pop() entries[i][1] = copy i++ } return Object.fromEntries(entries) } } myCopy = cp_stack(MyObject)
moar hand (un)rolling
const cp_keys=(obj)=>{ if ("object" !== typeof obj) { return obj } else { const stack = [] let keys = Object.keys(obj) let copy = obj instanceof Array ? [] : {} let i=0 stackloop: while(true) { for(; i < keys.length; i++) { const k = keys[i] if ("object" !== typeof obj[k]) { copy[k]=obj[k] } else { stack.push([obj,keys,copy,i]) obj = obj[k] keys = Object.keys(obj) copy = obj instanceof Array ? [] : {} i = 0 continue stackloop } } if (stack.length === 0) break const buff = copy ;[obj,keys,copy,i] = stack.pop() copy[keys[i]] = buff i++ } return copy } } myCopy = cp_keys(MyObject)
roll it back up bruh
const cp_keys_recursive=(obj)=>{ if ("object" !== typeof obj) { return obj } else { let keys = Object.keys(obj) let copy = obj instanceof Array ? [] : {} for(let i=0; i < keys.length; i++) { const k = keys[i] if ("object" !== typeof obj[k]) { copy[k]=obj[k] } else { copy[k]=cp_keys_recursive(obj[k]) } } return copy } } myCopy = cp_keys_recursive(MyObject)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (8)
Previous results
Fork
Test case name
Result
Lodash cloneDeep
Json clone
Ramda clone
hand rolled
loop not map (still recursive)
original gangster
moar hand (un)rolling
roll it back up bruh
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 seems like you're ready to dive into the world of benchmarking and benchmark results. Based on the provided information, I'll provide an answer: **The Answer** The benchmark results show the performance of different JavaScript clones (Ramda, Lodash, Json, etc.) in a Chrome 79 browser on a Mac OS X 10.15.2 desktop. **Interpretation** These results suggest that Ramda has a slight edge over the other clones in terms of execution speed. However, the differences are relatively small, and there's some variation between runs. If you're interested in optimizing your code for better performance, consider exploring ways to reduce recursive function calls, using caching or memoization, and leveraging browser-specific optimizations. Please let me know if you have any further questions or need help with interpreting these results!
Related benchmarks:
Lodash cloneDeep vs JSON Clone (Large Object 2)
Lodash vs JSON vs Ramda Clone vs old school ugly with moar json
Lodash vs JSON vs Ramda Clone vs fixed old school ugly with moar json
Lodash vs JSON vs Ramda vs the oooh geee
Comments
Confirm delete:
Do you really want to delete benchmark?