Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash vs Ramda 2020-09-01
(version: 0)
Comparing performance of:
Lodash vs Ramda without relying on currying or composition vs Ramda with currying and composition
Created:
5 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.27.1/ramda.min.js" integrity="sha512-rZHvUXcc1zWKsxm7rJ8lVQuIr1oOmm7cShlvpV0gWf0RvbcJN6x96al/Rp2L2BI4a4ZkT2/YfVe/8YvB2UHzQw==" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.20/lodash.min.js" integrity="sha512-90vH1Z83AJY9DmlWa8WkjkV79yfS2n2Oxhsi2dZbIv0nC4E6m5AbH8Nh156kkM7JePmqD6tcZsfad1ueoaovww==" crossorigin="anonymous"></script>
Script Preparation code:
var data = _.range(10000).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) .map(item => item.counter) .filter(isOdd) .map(square) .filter(lessThanThreeDigits) .value();
Ramda without relying on 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 relying on 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):
Let's dive into the benchmark and explain what's being tested. **Benchmark Overview** The benchmark compares the performance of Lodash and Ramda, two popular functional programming libraries for JavaScript. The test consists of three individual test cases: 1. **Lodash**: Tests the `chain` method from Lodash, which is used to create a pipeline of functions that operate on data. 2. **Ramda without currying or composition**: Tests the `filter` function from Ramda, but without relying on its currying and composition features. Instead, it uses the `map` function to apply a transformation to each element of the input data. 3. **Ramda with currying and composition**: Tests the `pipe` function from Ramda, which is used to compose multiple functions together. **Options Compared** The benchmark compares three different approaches: * Lodash's `chain` method * Ramda's `filter` function without currying or composition * Ramda's `pipe` function with currying and composition **Pros and Cons of Each Approach** 1. **Lodash's `chain` method**: This approach is easy to read and write, as it uses a simple chain of functions to operate on data. However, it may not be the most efficient way to perform these operations, as each function call creates a new object. * Pros: Easy to understand and use * Cons: May not be efficient due to multiple function calls 2. **Ramda's `filter` without currying or composition**: This approach is more concise than Lodash's `chain`, but may require more manual iteration over the data. * Pros: More concise, can avoid unnecessary iterations * Cons: Requires more manual iteration, which can be error-prone 3. **Ramda's `pipe` with currying and composition**: This approach is often considered the most expressive and efficient way to compose functions together. However, it may require more mental effort to understand. * Pros: More expressive and efficient, can avoid unnecessary iterations * Cons: Requires more mental effort to understand **Library Used** In this benchmark, both Lodash and Ramda are used as external libraries. Lodash provides a range of functional programming utilities, including `chain`, `map`, and others. Ramda is a lightweight library that provides a more concise and expressive way to perform common functional programming operations. **Special JS Features/Syntax** The benchmark uses some special JavaScript features and syntax: * Arrow functions (`=>`) are used in the test cases. * The `filter` method is used with a callback function (e.g., `isOdd(num)`). * The `pipe` function from Ramda is used to compose multiple functions together. **Other Alternatives** If you're interested in exploring other alternatives, there are several other functional programming libraries for JavaScript that you can consider: * **Es6 Promise**: Provides a built-in way to handle asynchronous operations using promises. * **Preact**: A lightweight alternative to React, which provides a more concise and efficient way to build user interfaces. * **RxJS**: A reactive programming library that provides a more declarative way to handle asynchronous data streams. Keep in mind that each of these alternatives has its own strengths and weaknesses, and the choice ultimately depends on your specific use case and requirements.
Related benchmarks:
Lodash vs Ramda vs Underscore 1.9.0 vs native
Lodash vs Ramda (2020-08 edition)
Lodash vs Ramda vs Native 2020-09-01
Ramda vs Native .chain
Comments
Confirm delete:
Do you really want to delete benchmark?