Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Native delete vs Lodash omit vs Lodash pick - multiple properties
(version: 0)
Comparing performance of:
Native delete vs Lodash pick vs Lodash omit
Created:
3 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js"></script>
Script Preparation code:
data = { abf:'asd',message:'koko', msg1: 'abc', msg2: 'def', msg3: 'ghi' }
Tests:
Native delete
const meta = Object.assign({}, data); delete meta.message; delete meta.msg1; delete meta.msg2; delete meta.msg3; return { message: data.message, meta }
Lodash pick
return { message: _.pick(data, ['message', 'msg1', 'msg2', 'msg3']) }
Lodash omit
return { message: data.message, meta: _.omit(data, ['message', 'msg1', 'msg2', 'msg3']) }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Native delete
Lodash pick
Lodash omit
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; rv:128.0) Gecko/20100101 Firefox/128.0
Browser/OS:
Firefox 128 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Native delete
196699.8 Ops/sec
Lodash pick
224723.5 Ops/sec
Lodash omit
148202.2 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's dive into the world of JavaScript benchmarks. **What is being tested?** The provided JSON represents a benchmark test that compares the performance of three approaches: 1. Native JavaScript `delete` operator 2. Lodash's `omit` function (which removes specified properties from an object) 3. Lodash's `pick` function (which selects specific properties from an object) **Options being compared** The three options being compared are: * Native JavaScript `delete`: This approach uses the native `delete` operator to delete properties from the `data` object. * Lodash's `omit`: This approach uses the `omit` function from the Lodash library to remove specified properties from the `data` object. The `omit` function takes an array of property names as its second argument, and returns a new object with those properties removed. * Lodash's `pick`: This approach uses the `pick` function from the Lodash library to select specific properties from the `data` object. Like `omit`, it takes an array of property names as its second argument. **Pros and Cons** Here are some pros and cons of each approach: * Native JavaScript `delete`: + Pros: Fast, lightweight, and doesn't require any additional libraries. + Cons: May not be as efficient as the Lodash functions for large objects or when dealing with complex property names. * Lodash's `omit`: + Pros: Flexible and powerful, allows for removal of properties by name or by regex pattern. + Cons: Requires an additional library (Lodash), which may add overhead to the test. * Lodash's `pick`: + Pros: Fast and efficient, allows for selection of multiple properties at once. + Cons: Requires an additional library (Lodash), which may add overhead to the test. **Library usage** The Lodash library is being used in two of the three options: * `omit`: Used to remove specified properties from the `data` object. * `pick`: Used to select specific properties from the `data` object. Both functions take an array of property names as their second argument, which allows for flexible and powerful filtering of the object's properties. **Special JS features or syntax** None of the options in this benchmark test use any special JavaScript features or syntax that would affect the performance comparison. However, it's worth noting that the `delete` operator is a feature of JavaScript that was introduced in ECMAScript 2015 (ES6), and its usage may vary depending on the version of JavaScript being used. **Alternative approaches** There are other ways to achieve similar results without using Lodash: * Using a simple loop or recursive function to delete properties * Using a third-party library like Underscore.js instead of Lodash * Implementing a custom property removal or selection mechanism However, these alternatives may not be as efficient or convenient as the Lodash functions, and are likely to add additional overhead to the test. I hope this explanation helps!
Related benchmarks:
Lodash omit vs Native delete
Lodash omit vs Native delete vs Native destruct - Mantz
Lodash omit vs Native delete - Mav
Native delete vs Lodash omit - multiple properties
Comments
Confirm delete:
Do you really want to delete benchmark?