Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Object.keys vs loadash isEmpty large object
(version: 0)
Comparing performance of:
Lodash isEmpty vs Object.keys
Created:
2 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.20/lodash.min.js"></script>
Script Preparation code:
var sampleObject = { "kind": "youtube#searchListResponse", "etag": "q4ibjmYp1KA3RqMF4jFLl6PBwOg", "nextPageToken": "CAUQAA", "regionCode": "NL", "pageInfo": {"totalResults": 1000000, "resultsPerPage": 5}, "items": [ { "kind": "youtube#searchResult", "etag": "QCsHBifbaernVCbLv8Cu6rAeaDQ", "id": {"kind": "youtube#video", "videoId": "TvWDY4Mm5GM"}, "snippet": { "publishedAt": "2023-07-24T14:15:01Z", "channelId": "UCwozCpFp9g9x0wAzuFh0hwQ", "title": "3 Football Clubs Kylian Mbappe Should Avoid Signing ✍️❌⚽️ #football #mbappe #shorts", "description": "", "thumbnails": { "default": { "url": "https://i.ytimg.com/vi/TvWDY4Mm5GM/default.jpg", "width": 120, "height": 90 }, "medium": { "url": "https://i.ytimg.com/vi/TvWDY4Mm5GM/mqdefault.jpg", "width": 320, "height": 180 }, "high": { "url": "https://i.ytimg.com/vi/TvWDY4Mm5GM/hqdefault.jpg", "width": 480, "height": 360 } }, "channelTitle": "FC Motivate", "liveBroadcastContent": "none", "publishTime": "2023-07-24T14:15:01Z" } }, { "kind": "youtube#searchResult", "etag": "0NG5QHdtIQM_V-DBJDEf-jK_Y9k", "id": {"kind": "youtube#video", "videoId": "aZM_42CcNZ4"}, "snippet": { "publishedAt": "2023-07-24T16:09:27Z", "channelId": "UCM5gMM_HqfKHYIEJ3lstMUA", "title": "Which Football Club Could Cristiano Ronaldo Afford To Buy? 💰", "description": "Sign up to Sorare and get a FREE card: https://sorare.pxf.io/NellisShorts Give Soraredata a go for FREE: ...", "thumbnails": { "default": { "url": "https://i.ytimg.com/vi/aZM_42CcNZ4/default.jpg", "width": 120, "height": 90 }, "medium": { "url": "https://i.ytimg.com/vi/aZM_42CcNZ4/mqdefault.jpg", "width": 320, "height": 180 }, "high": { "url": "https://i.ytimg.com/vi/aZM_42CcNZ4/hqdefault.jpg", "width": 480, "height": 360 } }, "channelTitle": "John Nellis", "liveBroadcastContent": "none", "publishTime": "2023-07-24T16:09:27Z" } }, { "kind": "youtube#searchResult", "etag": "WbBz4oh9I5VaYj91LjeJvffrBVY", "id": {"kind": "youtube#video", "videoId": "wkP3XS3aNAY"}, "snippet": { "publishedAt": "2023-07-24T16:00:50Z", "channelId": "UC4EP1dxFDPup_aFLt0ElsDw", "title": "PAULO DYBALA vs THE WORLD'S LONGEST FREEKICK WALL", "description": "Can Paulo Dybala curl a football around the World's longest free kick wall? We met up with the World Cup winner and put him to ...", "thumbnails": { "default": { "url": "https://i.ytimg.com/vi/wkP3XS3aNAY/default.jpg", "width": 120, "height": 90 }, "medium": { "url": "https://i.ytimg.com/vi/wkP3XS3aNAY/mqdefault.jpg", "width": 320, "height": 180 }, "high": { "url": "https://i.ytimg.com/vi/wkP3XS3aNAY/hqdefault.jpg", "width": 480, "height": 360 } }, "channelTitle": "Shoot for Love", "liveBroadcastContent": "none", "publishTime": "2023-07-24T16:00:50Z" } }, { "kind": "youtube#searchResult", "etag": "juxv_FhT_l4qrR05S1QTrb4CGh8", "id": {"kind": "youtube#video", "videoId": "rJkDZ0WvfT8"}, "snippet": { "publishedAt": "2023-07-24T10:00:39Z", "channelId": "UCO8qj5u80Ga7N_tP3BZWWhQ", "title": "TOP 10 DEFENDERS 2023", "description": "SoccerKingz https://soccerkingz.nl Use code: 'ILOVEHOF' to get 10% off. TOP 10 DEFENDERS 2023 Follow us! • Instagram ...", "thumbnails": { "default": { "url": "https://i.ytimg.com/vi/rJkDZ0WvfT8/default.jpg", "width": 120, "height": 90 }, "medium": { "url": "https://i.ytimg.com/vi/rJkDZ0WvfT8/mqdefault.jpg", "width": 320, "height": 180 }, "high": { "url": "https://i.ytimg.com/vi/rJkDZ0WvfT8/hqdefault.jpg", "width": 480, "height": 360 } }, "channelTitle": "Home of Football", "liveBroadcastContent": "none", "publishTime": "2023-07-24T10:00:39Z" } }, { "kind": "youtube#searchResult", "etag": "wtuknXTmI1txoULeH3aWaOuXOow", "id": {"kind": "youtube#video", "videoId": "XH0rtu4U6SE"}, "snippet": { "publishedAt": "2023-07-21T16:30:05Z", "channelId": "UCwozCpFp9g9x0wAzuFh0hwQ", "title": "3 Things You Didn’t Know About Erling Haaland ⚽️🇳🇴 #football #haaland #shorts", "description": "", "thumbnails": { "default": { "url": "https://i.ytimg.com/vi/XH0rtu4U6SE/default.jpg", "width": 120, "height": 90 }, "medium": { "url": "https://i.ytimg.com/vi/XH0rtu4U6SE/mqdefault.jpg", "width": 320, "height": 180 }, "high": { "url": "https://i.ytimg.com/vi/XH0rtu4U6SE/hqdefault.jpg", "width": 480, "height": 360 } }, "channelTitle": "FC Motivate", "liveBroadcastContent": "none", "publishTime": "2023-07-21T16:30:05Z" } } ] }
Tests:
Lodash isEmpty
isEmpty = _.isEmpty(sampleObject);
Object.keys
isEmpty = Object.keys(sampleObject).length === 0;
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Lodash isEmpty
Object.keys
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 YaBrowser/24.6.0.0 Safari/537.36
Browser/OS:
Yandex Browser 24 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Lodash isEmpty
3887387.8 Ops/sec
Object.keys
4482495.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
A large JSON object and some individual test cases, plus benchmark results! After analyzing the JSON object, I see that it's a sample YouTube search result with a `thumbnails` section containing three thumbnail sizes (default, medium, high) for a video. The individual test cases are: 1. Lodash `isEmpty` function on the `sampleObject` 2. Checking if an object is empty using `Object.keys` And finally, there are two benchmark results from Yandex Browser 24, comparing the execution times of these two test cases: **Lodash `isEmpty`**: 4482495 executions per second **Object.keys**: 3887387.75 executions per second Since no specific question was asked, I'll assume you want me to explain or provide insights on these results. The Lodash `isEmpty` function seems to be slightly faster than the manual `Object.keys` approach. However, the performance difference is relatively small (about 15%). This might not be significant in all cases, but it's an interesting observation nonetheless! If I had to make a prediction or suggestion, I'd say that if you're working with large datasets and need to frequently check for emptiness, using a dedicated library like Lodash might provide a minor performance boost. On the other hand, if you're only working with small objects or have specific requirements that prevent you from using libraries, the manual `Object.keys` approach might be sufficient. Let me know if there's anything else I can help with!
Related benchmarks:
key exists: key in object vs !!object[key]
key exists: key in object vs !!object[key] vs object[key]
hash-sum (2.0) vs object-hash (3.0) (BIG and diff order)
JSON.stringify vs structuredClone with large Objects 2
lodash clone vs. JSON.parse(JSON.stringify()) vs. fastest-json-copy | On a Big Object
Comments
Confirm delete:
Do you really want to delete benchmark?