Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
lodash omit vs filter
(version: 0)
Comparing performance of:
omit vs filter
Created:
5 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>
Tests:
omit
const foo = ['field1', 'field2', 'field3', 'field4', 'field5']; _.omit(foo, nextField => nextField === 'field4');
filter
const foo = ['field1', 'field2', 'field3', 'field4', 'field5']; _.filter(foo, nextField => nextField !== 'field4');
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
omit
filter
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 years ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Browser/OS:
Chrome 120 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
omit
486989.3 Ops/sec
filter
3170910.2 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down what is being tested on the provided JSON. **Benchmark Definition** The benchmark is defined by two test cases, "filter" and "omit", which compare the performance of two methods in the Lodash library: `_.omit` and `_filter`. **Options Compared** In this benchmark, the following options are compared: 1. **_.omit**: Removes specified fields from an array. 2. **_.filter**: Creates a new array with only the elements that pass a test implemented by the provided function. **Pros and Cons of Each Approach** * **_.omit**: This approach is generally faster because it only needs to create a new array with the desired fields removed, whereas `_filter` creates a new array and then iterates over it. However, if the input array is small, the overhead of creating a new array might outweigh the speed benefit. * **_.filter**: This approach can be more intuitive for developers familiar with JavaScript's `Array.prototype.filter()` method. However, as mentioned earlier, it has an additional overhead due to the iteration and creation of a new array. **Library: Lodash** Lodash is a popular JavaScript library that provides various utility functions, including those used in this benchmark (e.g., `_omit`, `_filter`). It aims to provide a comprehensive set of functions for common programming tasks. **Special JS Feature/Syntax** There is no special JavaScript feature or syntax being tested in this benchmark. The code only uses standard JavaScript and Lodash library functions. **Other Alternatives** If you wanted to compare the performance of other methods, here are some alternatives: * **Manual Array Iteration**: Instead of using `_omit` or `_filter`, developers could manually iterate over the input array and create a new array with the desired fields removed. * **Array.prototype.forEach()**: Similar to manual iteration, but uses `forEach()` instead. Keep in mind that these alternatives would likely be slower than using Lodash's optimized `_omit` and `_filter` functions.
Related benchmarks:
without vs filter
lodash.filter vs js native
Lodash.filter vs Lodash.without
Lodash.filter vs Lodash.without vs array.filter
Lodash filter VS native filter (with Lodash actually loaded)
Comments
Confirm delete:
Do you really want to delete benchmark?