Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
filter: ramda vs native
(version: 0)
Comparing performance of:
R.filter(modulo, data); vs data.filter(modulo);
Created:
8 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src="//cdnjs.cloudflare.com/ajax/libs/ramda/0.25.0/ramda.min.js"></script>
Script Preparation code:
function modulo(n) { return n % 3 === 0; } var data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30];
Tests:
R.filter(modulo, data);
R.filter(modulo, data);
data.filter(modulo);
data.filter(modulo);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
R.filter(modulo, data);
data.filter(modulo);
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/127.0.0.0 Safari/537.36
Browser/OS:
Chrome 127 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
R.filter(modulo, data);
4888636.0 Ops/sec
data.filter(modulo);
3201156.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'd be happy to help explain the benchmark and its results. **Benchmark Overview** The benchmark is designed to compare the performance of two approaches: using the Ramda library's `filter` function (denoted as "R.filter") versus the native JavaScript `filter` function. The test case involves creating a small array `data` with 30 elements, defining a simple modulo function `modulo`, and then applying this function to the data array using both the Ramda and native approaches. **Options Compared** The two options being compared are: 1. **R.filter**: This is the Ramda library's implementation of the `filter` function. The Ramda library provides a functional programming approach to JavaScript, allowing developers to write more concise and expressive code. 2. **data.filter**: This is the native JavaScript `filter` function, which is part of the built-in JavaScript language. **Pros and Cons** Here are some pros and cons of each approach: * **R.filter**: + Pros: Provides a functional programming approach that can lead to more concise and composable code. Ramda also provides other useful functions for data processing. + Cons: Requires an additional library to be included in the project, which may add overhead. * **data.filter**: + Pros: Is part of the built-in JavaScript language, so no additional libraries are required. + Cons: Can lead to more verbose code and a less functional programming approach. **Library: Ramda** Ramda is a popular JavaScript library for functional programming. It provides a wide range of functions for data processing, filtering, mapping, reducing, and more. The `filter` function in Ramda takes two arguments: the predicate function (in this case, `modulo`) and the array to filter. **Special JS Feature/Syntax** There are no special JavaScript features or syntaxes being tested in this benchmark. **Benchmark Preparation Code** The preparation code includes: * A simple modulo function `modulo` that returns `true` if the input is divisible by 3. * An array `data` with 30 elements, ranging from 1 to 30. **Individual Test Cases** There are two test cases: 1. **R.filter**: Applies the `filter` function from Ramda to the `data` array using the `modulo` predicate function. 2. **data.filter**: Applies the native JavaScript `filter` function to the `data` array using the same `modulo` predicate function. **Latest Benchmark Results** The latest benchmark results show that: * The R.filter approach executes at a rate of 4888636 executions per second on Chrome 127, running on a Mac OS X 10.15.7 system. * The data.filter approach executes at a rate of 3201156 executions per second on the same system and browser. These results suggest that Ramda's `filter` function is faster than the native JavaScript `filter` function in this specific benchmark. However, it's essential to note that this may not be representative of all scenarios or use cases, and more testing would be needed to confirm these findings.
Related benchmarks:
Ramda map vs Array.map
Map (Native vs Ramda vs Lodash vs Immutable)
Map (Native vs Ramda vs Lodash vs Lodash/fp vs Immutable)
Map (Native vs Ramda vs Lodash vs Immutable
Comments
Confirm delete:
Do you really want to delete benchmark?