Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
y7898yiykhu
(version: 4)
Comparing performance of:
Ramda vs lodash fp
Created:
6 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src="//cdnjs.cloudflare.com/ajax/libs/ramda/0.27.0/ramda.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.15/lodash.fp.js"></script>
Script Preparation code:
var data = Array(10000).fill().map(function(_, i) { return { counter: i } }); function isOdd(num) { return num % 2 === 1; } function square(num) { return num * num; } function lessThanThreeDigits(num) { return num.toString().length < 3; }
Tests:
Ramda
var result = R.pipe( R.map(x => x.counter), R.filter(isOdd), R.map(square), R.filter(lessThanThreeDigits) )(data);
lodash fp
var result = _.flow( _.map(x => x.counter), _.filter(isOdd), _.map(square), _.filter(lessThanThreeDigits), )(data);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Ramda
lodash fp
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.1:latest
, generated one year ago):
Let's dive into the provided JSON and explore what's being tested. **Benchmark Definition** The benchmark definition creates an array of 10,000 objects with a `counter` property ranging from 0 to 9,999. The script then defines three functions: `isOdd`, `square`, and `lessThanThreeDigits`. These functions are used in the test cases to filter and transform the data. **Test Cases** There are two test cases: 1. **Ramda**: This test case uses the Ramda library to pipe four functions together: * `R.map(x => x.counter)`: Extracts the `counter` property from each object. * `R.filter(isOdd)`: Filters the results to only include odd numbers (using the `isOdd` function). * `R.map(square)`: Squares each number (using the `square` function). * `R.filter(lessThanThreeDigits)`: Filters the results to only include numbers with less than three digits (using the `lessThanThreeDigits` function). 2. **Lodash FP**: This test case uses Lodash's functional programming API (`_.flow`) to compose four functions together: * `_.map(x => x.counter)`: Extracts the `counter` property from each object. * `_.filter(isOdd)`: Filters the results to only include odd numbers (using the `isOdd` function). * `_.map(square)`: Squares each number (using the `square` function). * `_.filter(lessThanThreeDigits)`: Filters the results to only include numbers with less than three digits (using the `lessThanThreeDigits` function). **Ramda and Lodash libraries** The test cases use two popular JavaScript libraries: 1. **Ramda**: A utility library that provides functional programming helpers, such as `pipe`, `map`, `filter`, etc. 2. **Lodash FP**: A part of the Lodash library, which provides a set of functional programming utilities. **JS feature or syntax** There are no special JavaScript features or syntax used in this benchmark. The code is straightforward and uses standard JavaScript functions and methods. **What's being compared?** The test cases compare the execution performance of two different approaches to pipe four functions together: 1. **Ramda**: Using Ramda's `pipe` function to compose the four functions. 2. **Lodash FP**: Using Lodash's `_.flow` function to compose the same four functions. **Pros and Cons** Based on the results, it appears that Ramda's approach is faster than Lodash's functional programming API. However, this might not be a general conclusion, as the performance difference may depend on specific use cases or input data. Other considerations: * The test case uses a relatively small dataset (10,000 objects). * The functions used in the test case are simple and do not have any side effects. * The benchmark is run on a single machine with a modern browser (Chrome 80). **Alternatives** Some alternative approaches to consider include: 1. **Using vanilla JavaScript**: Instead of using libraries like Ramda or Lodash, you could implement your own functional programming helpers or use standard JavaScript methods and functions. 2. **Other functional programming libraries**: There are other libraries available that provide similar functionality, such as Underscore.js or Immutable.js. Keep in mind that the best approach depends on specific requirements, performance needs, and personal preferences.
Related benchmarks:
Lodash vs Ramda
Lodash vs Ramda (2020-08 edition)
Lodash vs Ramda 2020-09-01
Lodash vs Ramdasdfsdf
Ramda vs Native .chain
Comments
Confirm delete:
Do you really want to delete benchmark?