Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Object Deconstruction vs Lodash Pick
(version: 0)
Comparing performance of:
Lodash pick vs Deconstruction
Created:
3 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.11/lodash.min.js"></script>
Script Preparation code:
var production = { "_id": 21518, "ownerId": 257412, "title": "Validation Production Attempt ", "tags": [ "austen" ], "index": "0", "sub_index": "0", "xDimension": 1920, "yDimension": 1080, "type": "legacy", "timeline": [], "looped": true, "muted": true, "timelineLocked": false, "playing": true, "videoPlaying": true, "version": "2.0", "created": 1655486623358, "createdById": 257412, "modified": 1657385697526, "modifiedById": 268244, "flagged": true, "createdBy": { "network": "auth0", "networkId": "auth0|61310e816228b40069268ca5", "username": "61310e816228b40069268ca5", "displayName": "Austen", "profileImageUrl": "https://s.gravatar.com/avatar/ee834f024bafb545e326e55a6f37279c?s=480&r=pg&d=https%3A%2F%2Fcdn.auth0.com%2Favatars%2Fau.png", "mfa_enabled": false }, "modifiedBy": { "network": "auth0", "networkId": "auth0|621fa9a077c303006881ba34", "username": "621fa9a077c303006881ba34", "displayName": "Vanessa Keeton", "profileImageUrl": "https://s.gravatar.com/avatar/3ced512d9d4bdff3034e058d989eb216?s=480&r=pg&d=https%3A%2F%2Fcdn.auth0.com%2Favatars%2Fva.png", "mfa_enabled": false }, "ownedBy": { "network": "auth0", "networkId": "auth0|61310e816228b40069268ca5", "username": "61310e816228b40069268ca5", "displayName": "Austen", "profileImageUrl": "https://s.gravatar.com/avatar/ee834f024bafb545e326e55a6f37279c?s=480&r=pg&d=https%3A%2F%2Fcdn.auth0.com%2Favatars%2Fau.png", "mfa_enabled": false }, "display_token": "5e22058ba3e5d000128d916a" }
Tests:
Lodash pick
const apiApprovedProps = _.pick( production, 'xDimension', 'yDimension', 'title', 'backgroundColor', 'transition', 'index', 'sub_index', 'timeline', 'tags', 'looped', 'muted', 'timelineLocked', 'videoPlaying', 'playing', 'kiosk_mode', 'flagged', ); console.log(apiApprovedProps);
Deconstruction
const apiApprovedProps = (({ xDimension, yDimension, title, backgroundColor, transition, index, sub_index, timeline, tags, looped, muted, timelineLocked, videoPlaying, playing, kiosk_mode, flagged, }) => ({ xDimension, yDimension, title, backgroundColor, transition, index, sub_index, timeline, tags, looped, muted, timelineLocked, videoPlaying, playing, kiosk_mode, flagged, }))(production); console.log(apiApprovedProps);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Lodash pick
Deconstruction
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 break down the benchmark definition and explain what's being tested. **Benchmark Definition** The benchmark is comparing two approaches to extract specific properties from an object: 1. **Deconstruction**: Using JavaScript's destructuring syntax to extract the desired properties from the `production` object. 2. **Lodash Pick**: Using the Lodash library's `pick()` function to extract the desired properties from the `production` object. **Deconstruction** Deconstruction is a feature introduced in ECMAScript 2018 (ES10) that allows you to extract values from an object into separate variables using destructuring syntax. In this benchmark, deconstruction is used to extract the following properties: ```javascript const apiApprovedProps = ({ xDimension, yDimension, title, backgroundColor, transition, index, sub_index, timeline, tags, looped, muted, timelineLocked, videoPlaying, playing, kiosk_mode, flagged }) => ({ xDimension, yDimension, title, backgroundColor, transition, index, sub_index, timeline, tags, looped, muted, timelineLocked, videoPlaying, playing, kiosk_mode, flagged }); ``` **Lodash Pick** The Lodash library provides a `pick()` function that allows you to extract specific properties from an object. In this benchmark, the `pick()` function is used to extract the following properties: ```javascript const apiApprovedProps = _.pick( production, 'xDimension', 'yDimension', 'title', 'backgroundColor', 'transition', 'index', 'sub_index', 'timeline', 'tags', 'looped', 'muted', 'timelineLocked', 'videoPlaying', 'playing', 'kiosk_mode', 'flagged' ); ``` **Pros and Cons** Here's a brief summary of the pros and cons of each approach: **Deconstruction:** Pros: * Native JavaScript support * Faster execution (since it doesn't require an external library) * Easier to read and understand Cons: * Requires ECMAScript 2018 (ES10) or later support * Limited flexibility (requires explicit property extraction) **Lodash Pick:** Pros: * Wider compatibility (works with older browsers) * More flexible (can extract multiple properties at once) * No native JavaScript support, but still relatively fast Cons: * Requires an external library (Lodash) * Slower execution compared to deconstruction * May require more code to read and understand **Benchmark Result** The benchmark result shows the performance difference between the two approaches. The deconstruction approach outperforms the Lodash `pick()` function, with a higher executions per second rate. Keep in mind that this is just a brief analysis, and there may be other factors affecting the performance of these benchmarks.
Related benchmarks:
filter vs compact v2
filter vs compact vs flat
filter vs compact vs native
lodash compact vs native filter
lodash compact vs native filter vs lodash filter
Comments
Confirm delete:
Do you really want to delete benchmark?