Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Ramda vs lodash latest
(version: 0)
Comparing performance of:
Loadsh vs Ramda without currying vs Ramda with test case
Created:
one year ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="//cdnjs.cloudflare.com/ajax/libs/ramda/0.30.1/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(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:
Loadsh
var result = _.chain(data) .pick('counter') .filter(isOdd) .map(square) .filter(lessThanThreeDigits) .value();
Ramda without currying
var result = R.filter(lessThanThreeDigits, R.map(square, R.filter(isOdd, R.pluck('counter', data))));
Ramda with test case
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
Loadsh
Ramda without currying
Ramda with test case
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
6 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 Edg/141.0.0.0
Browser/OS:
Chrome 141 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Loadsh
1265366.9 Ops/sec
Ramda without currying
2296.1 Ops/sec
Ramda with test case
2078.1 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Measuring performance differences between two popular JavaScript libraries, Ramda and Lodash, is crucial for developers who need to optimize their code. **Benchmark Test Case Analysis** The provided benchmark test cases use both Lodash and Ramda to perform similar operations on a dataset. The goal is to determine which library performs better in terms of execution speed. **Lodash (latest version)** * **`_.chain(data)`: Creates a new chainable object from the input data. * **`.pick('counter')`: Selects only the 'counter' property from each element in the chain. * **`.filter(isOdd)`: Filters out elements where `isOdd` returns false. * **`.map(square)`: Applies the square function to each remaining element. * **`.filter(lessThanThreeDigits)`: Filters out elements with more than 3 digits. * **`.value()`: Returns the final filtered array. The test case using Lodash's pipeline approach (`var result = _.chain(data)...`) tests how efficient it is to use a series of functions chained together. **Ramda** * Ramda is a functional programming library for JavaScript. * The `R.filter` function filters out elements based on a predicate function. * The `R.map` function applies a given function to each element in the input data. * The `R.pluck` function returns an array of selected values from an object or array. * The `R.pipe` function is used to compose multiple functions together. **Test Cases** There are three test cases: 1. **Ramda without currying**: Tests how Ramda performs when not using its curried function syntax (e.g., `var result = R.filter(lessThanThreeDigits, ...)`). 2. **Ramda with test case**: Tests the efficiency of using Ramda's pipeline approach (`var result = R.pipe(...)(data)`) to perform a series of operations. 3. **Lodash (latest version)**: Tests how efficient Lodash is when using its chained function syntax. **Pros and Cons** * **Lodash** + Pros: - Well-established library with good support for various use cases. - Easy to understand and use, especially for developers familiar with JavaScript. + Cons: - Chained functions might lead to a loss of performance due to the overhead of creating new objects. * **Ramda** + Pros: - Designed for functional programming and provides an efficient way to compose operations using `R.pipe`. - Can be more concise than Lodash's chained syntax, especially when dealing with multiple operations. + Cons: - Might require additional learning for developers unfamiliar with functional programming concepts. **Other Considerations** * **Currying**: Ramda uses currying (partial application of functions) to improve performance and make its API more expressive. However, this approach can be less intuitive for some developers. * **Object creation overhead**: Both Lodash and Ramda create new objects when using their chained function syntax. This overhead might impact performance, especially when dealing with large datasets. **Benchmark Results** The provided benchmark results show the execution speed of each library on a specific test case. The RawUAString values indicate the browser and device platform used to run the tests.
Related benchmarks:
Ramda vs. Lodash 3
Ramda vs. Lodash updated
Ramda vs. Lodash updated again
Ramda vs. Lodash 2021
Ramda vs. Lodash 2021 v2
Comments
Confirm delete:
Do you really want to delete benchmark?