Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash omit VS pick
(version: 0)
Comparing performance of:
omit vs pick
Created:
4 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.15/lodash.min.js'></script>
Script Preparation code:
var MyObject = { description: 'a', myNumber: 123456789, myBoolean: true, }; var myCopy = null;
Tests:
omit
_.omit(MyObject, 'myNumber');
pick
_.pick(MyObject, 'myNumber');
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
omit
pick
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Browser/OS:
Chrome 134 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
omit
3365281.0 Ops/sec
pick
9061960.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
**Overview of the Benchmark** MeasureThat.net is a website that allows users to create and run JavaScript microbenchmarks, comparing different approaches to achieve the same result. In this case, we have a benchmark that tests two functions from the Lodash library: `omit` and `pick`. **Lodash Library** The Lodash library is a popular JavaScript utility library that provides various functions for tasks such as array manipulation, object manipulation, and more. In this benchmark, we're using version 4.17.15 of the library. **Benchmarked Functions** The two functions being tested are: 1. `_.omit(MyObject, 'myNumber')`: This function removes the property `myNumber` from the object `MyObject`. 2. `_.pick(MyObject, 'myNumber')`: This function adds the property `myNumber` to the object `MyObject`. **Comparison of Approaches** The two approaches being compared are: 1. **Lodash's `omit` function**: This function uses a simple implementation that creates a new object with only the properties specified in the second argument. 2. **Plain JavaScript approach**: The benchmark prepares a variable `myCopy` and assigns it an empty object, then updates this object using the `MyObject` object. **Pros and Cons of Each Approach** 1. **Lodash's `omit` function**: * Pros: Fast execution time, concise code. * Cons: May not be optimal for very large objects or complex properties. 2. **Plain JavaScript approach**: * Pros: Can handle very large objects or complex properties efficiently. * Cons: More verbose code. **Special Considerations** In this benchmark, there are no special considerations, such as using a specific JavaScript feature or syntax. **Other Alternatives** There may be other alternatives to Lodash's `omit` function, such as: 1. Using the `Object.create(null)` method to create an empty object. 2. Using the `Object.assign()` method to update the object. However, these alternatives are not being tested in this benchmark. Overall, the benchmark is testing how fast each approach can execute for a small set of properties. The results will help users determine which approach is best suited for their specific use case.
Related benchmarks:
Lodash omit VS delete
Lodash cloneDeep VS mutate
Lodash clone VS spread operator shallow
Object assign vs loadash clone 1
Comments
Confirm delete:
Do you really want to delete benchmark?