Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
underscore without vs filter
(version: 0)
Comparing performance of:
without vs filter
Created:
one year ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js'></script>
Script Preparation code:
var numbers = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17];
Tests:
without
const final = _.without(numbers, 16);
filter
const final = numbers.filter((num) => num !== 16);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
without
filter
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36
Browser/OS:
Chrome 123 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
without
777521.2 Ops/sec
filter
7452574.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the benchmark and explain what's being tested. **Benchmark Overview** The benchmark compares the performance of two approaches: `_.without(numbers, 16)` (using Underscore.js's `without` function) and `numbers.filter((num) => num !== 16)` (a custom implementation using the built-in `filter` method). **Options Compared** 1. **Underscore.js's `without` function**: This is a utility function provided by the Underscore.js library, which removes all occurrences of an element from an array while preserving the original order. 2. **Built-in `filter` method**: This is a standard JavaScript method that creates a new array with all elements that pass the test implemented by the provided function. **Pros and Cons** 1. **Underscore.js's `without` function**: * Pros: Generally faster than custom implementations due to optimized native code. * Cons: Requires an external library (Underscore.js), which might add overhead for some users. 2. **Built-in `filter` method**: * Pros: No external dependencies, easy to implement and understand. * Cons: Might be slower than the optimized implementation provided by Underscore.js. **Other Considerations** 1. **Performance**: The benchmark measures the performance of each approach in terms of executions per second. In this case, the custom `filter` implementation is slightly faster on Chrome 123 on Linux Desktop. 2. **Readability and Maintainability**: Using a built-in method like `filter` can be more readable and maintainable than implementing a custom solution. **Underscore.js Library** In the benchmark preparation code, Underscore.js version 1.8.3 is included using a CDN link (`https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js`). The `_.without` function is used to remove all occurrences of the element with index 16 from the `numbers` array. **JavaScript Feature/Syntax** There are no special JavaScript features or syntax used in this benchmark, apart from using modern JavaScript syntax like arrow functions (`(num) => num !== 16`) and template literals (`\r\n<script src='...'>`).
Related benchmarks:
underscore filter vs native
Underscore filter vs Array filter
lodash fp vs pure js
_.filter vs array filter (underscore)
Comments
Confirm delete:
Do you really want to delete benchmark?