Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash & Ramda
(version: 0)
Comparing performance of:
Lodash vs Ramda without currying or composition vs Ramda with currying and composition
Created:
6 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.25.0/ramda.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js"></script>
Script Preparation code:
var data = _.range(1000000).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:
Lodash
var result = _.chain(data) .pick('counter') .filter(isOdd) .map(square) .filter(lessThanThreeDigits) .value();
Ramda without currying or composition
var result = R.filter(lessThanThreeDigits, R.map(square, R.filter(isOdd, R.pluck('counter', data))));
Ramda with currying and composition
var result = R.pipe( R.pluck('counter'), R.filter(isOdd), R.map(square), R.filter(lessThanThreeDigits) )(data);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Lodash
Ramda without currying or composition
Ramda with currying and composition
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):
**Benchmark Overview** The provided JSON represents a JavaScript microbenchmarking test case created on MeasureThat.net. The benchmark tests two popular functional programming libraries: Lodash and Ramda. It measures the performance of each library in executing specific tasks, showcasing their differences in approach and syntax. **Test Cases** There are three individual test cases: 1. **Lodash**: This test case uses the Lodash library to chain a series of operations: * `_.chain(data)`: Create a pipeline from the input data. * `.pick('counter')`: Select only the 'counter' property from each object in the data. * `.filter(isOdd)` : Filter out even numbers using the `isOdd` function. * `.map(square)` : Square each remaining number. * `.filter(lessThanThreeDigits)` : Keep only numbers with less than 3 digits. * `.value()` : Return the final result as a single value. 2. **Ramda without currying or composition**: This test case uses Ramda's functional programming API but does not utilize its currying and composition features: * `R.filter(lessThanThreeDigits, R.map(square, R.filter(isOdd, R.pluck('counter', data))))`: Apply a series of functions sequentially using the pipe operator. 3. **Ramda with currying and composition**: This test case leverages Ramda's currying and composition features: * `R.pipe(R.pluck('counter'), R.filter(isOdd), R.map(square), R.filter(lessThanThreeDigits))(data)`: Apply a series of functions sequentially, where each function returns the output of the previous one. **Options Compared** The three test cases compare different approaches to functional programming: 1. **Lodash**: Uses chaining and method calls to execute the pipeline. 2. **Ramda without currying or composition**: Employs sequential application using the pipe operator, but without leveraging Ramda's advanced features. 3. **Ramda with currying and composition**: Utilizes Ramda's currying and composition features to create a more efficient and expressive pipeline. **Pros and Cons** Here are some general pros and cons for each approach: 1. **Lodash**: * Pros: Well-known and widely adopted, simple to read and understand. * Cons: Can be slower due to method call overhead. 2. **Ramda without currying or composition**: * Pros: Still a well-structured and readable API, with some performance benefits from sequential application. * Cons: May not leverage Ramda's full capabilities, resulting in less efficient code. 3. **Ramda with currying and composition**: * Pros: Can lead to more concise and expressive code, leveraging Ramda's advanced features for better performance. * Cons: May require a learning curve for developers unfamiliar with functional programming principles. **Library Considerations** The test case uses two popular JavaScript libraries: 1. **Lodash**: A widely used utility library providing a broad range of functions for tasks like array manipulation, string processing, and more. 2. **Ramda**: A functional programming library offering a powerful API for data processing and transformation, with features like currying, composition, and higher-order functions. **Special JavaScript Features** None of the test cases explicitly utilize any special JavaScript features or syntax, such as async/await or decorators.
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?