Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Filter-Map: Lodash vs Nati
(version: 0)
Comparing performance of:
Native filter-map vs Lodash filter-map vs ori_find vs lodash find vs my_find
Created:
7 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.4/lodash.min.js"></script>
Script Preparation code:
var data = [...Array(1000).keys()]
Tests:
Native filter-map
data.filter((e)=>{ e === 100})
Lodash filter-map
_.filter(data, (e)=>{ e === 100})
ori_find
data.find((e)=>{ e === 100})
lodash find
_.find(data, (e)=>{ e === 100})
my_find
function ori_find(array,target){ const i = array.length if(array[i] === target ){ return array[i] } if(array[i] > target ){ ori_find(animals.slice(0,i),target) } if(array[i] < target ){ ori_find(animals.slice(i+1),target) } } ori_find(data,250)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (5)
Previous results
Fork
Test case name
Result
Native filter-map
Lodash filter-map
ori_find
lodash find
my_find
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'll break down the benchmark and explain what's being tested, compared, and discussed. **Benchmark Overview** The benchmark compares four different implementations of finding an element in an array: 1. Native `filter`-map method (without any libraries) 2. Lodash's `_.filter` function 3. A custom implementation called `ori_find` 4. Another custom implementation called `my_find` **What is tested?** The benchmark tests the performance and execution time of each implementation on a given input array (`data`) with a specific target value (100). The test cases are: 1. Native `filter`-map method: uses the built-in `Array.prototype.filter()` and `Array.prototype.map()` methods 2. Lodash's `_.filter`: uses the Lodash library to implement the filtering functionality 3. `ori_find`: a custom implementation that manually iterates over the array to find the target value 4. `my_find`: another custom implementation similar to `ori_find`, but with some differences in the logic **Comparison of options** Here's a brief comparison of the four approaches: * **Native filter-map method**: Fast and efficient, as it leverages the optimized implementation of built-in methods. However, this approach assumes that the target value exists in the array. * **Lodash filter**: Uses an external library to implement filtering functionality. While Lodash is widely used and maintained, it may introduce additional overhead due to the library's initialization and garbage collection. * `ori_find`: A custom implementation that manually iterates over the array using a simple iterative approach. This approach is straightforward but can be slower than native methods or libraries like Lodash. * `my_find`: Similar to `ori_find`, but with some differences in logic, which might make it slightly faster or more efficient. **Pros and Cons** Here are some pros and cons of each approach: * Native filter-map method: + Pros: Fast, efficient, and optimized for built-in methods + Cons: Assumes target value exists in the array * Lodash filter: + Pros: Wide adoption and maintenance by the Lodash community + Cons: Additional overhead due to library initialization and garbage collection * `ori_find`: + Pros: Simple and straightforward implementation + Cons: Slower than native methods or libraries like Lodash * `my_find`: + Pros: Might be slightly faster or more efficient due to differences in logic + Cons: Requires careful analysis of the custom implementation to identify performance benefits **Library** Lodash is a popular JavaScript utility library that provides various functions for common tasks, such as array manipulation (`_.filter`, `_.map`), string manipulation (`_.trim`, `_._toUpperCase`), and more. The library's implementation uses techniques like caching, memoization, and optimized algorithms to improve performance. **Special JS features or syntax** There are no special JavaScript features or syntax mentioned in the benchmark that would require any specific knowledge of ES6+ features, such as arrow functions, classes, or async/await. **Alternatives** Other alternatives for implementing filtering functionality include: * Using a different library, such as Ramda or Immutable.js * Implementing custom filtering using bitwise operations (e.g., `Array.prototype.findIndex` with bitwise indexing) * Utilizing streaming algorithms or parallel processing techniques
Related benchmarks:
Filter-Map: Lodash chain vs Native
native lodash filter map
native lodash filter map 2
Map: Lodash vs Native
Comments
Confirm delete:
Do you really want to delete benchmark?