Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
filter vs _without (v3)
(version: 0)
Comparing performance of:
filter vs _without vs filter clear vs _without clear
Created:
3 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>
Script Preparation code:
var array = [...Array(100000).keys()]; var DEPRECATED = [98100]; var CLEAR_DEPRECATED = [];
Tests:
filter
array.filter(n => DEPRECATED.includes(n));
_without
_.without(array, ...DEPRECATED);
filter clear
array.filter(n => CLEAR_DEPRECATED.includes(n));
_without clear
_.without(array, ...CLEAR_DEPRECATED);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
filter
_without
filter clear
_without clear
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/131.0.0.0 Safari/537.36
Browser/OS:
Chrome 131 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
filter
1314.1 Ops/sec
_without
2065.4 Ops/sec
filter clear
1194.8 Ops/sec
_without clear
2184.4 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
**Overview** The provided JSON represents a benchmark test case for comparing the performance of two JavaScript methods: `Array.prototype.filter()` and Lodash's `_without()` function. **What is tested?** The benchmark tests the execution speed of these two methods when filtering out elements from an array. Specifically, it compares: 1. `Array.prototype.filter()`: The built-in JavaScript method for filtering out elements that don't meet a certain condition. 2. Lodash's `_without()`: A function from the Lodash library that filters out elements by passing an array of values to exclude. **Options compared** The benchmark compares the following two options: 1. **`Array.prototype.filter()`**: Uses the built-in JavaScript method for filtering out elements. 2. **Lodash's `_without()`**: Uses the Lodash library function for filtering out elements. **Pros and cons of each approach** * **`Array.prototype.filter()`**: + Pros: Fast, lightweight, and widely supported by browsers. + Cons: May not be as efficient for large arrays or complex filtering conditions. * **Lodash's `_without()`**: + Pros: Can handle larger arrays and more complex filtering conditions with ease. Lodash is a popular library that provides a wide range of utility functions. + Cons: Adds an additional dependency (the Lodash library) to the benchmark, which may not be desirable for smaller projects. **Library used** The benchmark uses the Lodash library version 4.17.5. Lodash is a popular JavaScript library that provides a collection of reusable functions for tasks such as array manipulation, string manipulation, and more. **Special JS feature or syntax** There are no special JS features or syntax used in this benchmark. **Other alternatives** For filtering out elements from an array, other alternatives to `Array.prototype.filter()` include: 1. **`Array.prototype.map()`.filter()`**: A two-step approach that first maps the array and then filters it. 2. **`Array.prototype.reduce()`**: A more complex approach that uses a callback function to filter the array. Keep in mind that these alternatives may have different performance characteristics compared to `Array.prototype.filter()` or Lodash's `_without()`.
Related benchmarks:
Array.prototype.filter vs Lodash without
Array.prototype.filter vs Lodash.without
Array.prototype.filter vs Lodash 4.17.5 filter
Array.prototype.filter vs Lodash without 2
Lodash.filter vs Lodash.without vs array.filter
Comments
Confirm delete:
Do you really want to delete benchmark?