Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
fwef132
(version: 0)
sdf
Comparing performance of:
ramda vs lo vs lodash fp
Created:
6 years ago
by:
Guest
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(100).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);
lo
var a = _.pick(data, 'counter') var b = _.filter(a, isOdd) var c = _.map(b, square) var d = _.filter(c, lessThanThreeDigits)
lodash fp
var result = _.flow( _.map(_.pick('counter')), _.filter(isOdd), _.map(square), _.filter(lessThanThreeDigits), )(data);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
ramda
lo
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 break down the benchmark test case. **Benchmark Description** The benchmark is testing the performance of three different JavaScript libraries: Ramda and Lodash, specifically their functional programming (FP) utilities. The goal is to compare the execution speed of these libraries when performing a series of operations on an array of objects. **Library Descriptions** 1. **Ramda**: A popular JavaScript library for functional programming. It provides a set of higher-order functions that can be composed together to perform complex data transformations. 2. **Lodash FP (Functional Programming)**: A subset of the Lodash library, which focuses on providing functional programming utilities. These utilities allow you to write more concise and composable code. **Test Case Description** The test case creates an array `data` containing 100 objects with a single property called `counter`. The goal is to filter this array based on three conditions: 1. Select only the objects where the `counter` value is odd (using the `isOdd` function). 2. Square the counter values of the selected objects (using the `square` function). 3. Filter out the squared values that are less than 3 digits long (using the `lessThanThreeDigits` function). **Test Cases** The test case has three variations: 1. **Ramda**: Uses Ramda's pipeline (`R.pipe`) to compose the three operations: mapping, filtering, and squaring. 2. **Lodash FP (lo)**: Uses Lodash's functional programming utilities (`_.pick`, `_.filter`, `_.map`, `_.filter`) to perform the same operations as above. 3. **Lodash FP (lodash fp)**: Similar to the previous test case, but uses Lodash's `.flow` method to compose the operations. **Benchmark Results** The results show that the Chrome 80 browser on a Mac OS X 10.15.4 desktop platform executes each test case at different speeds: * Ramda (`ramda` test case): 62,468 executions per second * Lodash FP (lo) (`lo` test case): 61,000 executions per second * Lodash FP (lodash fp) (`lodash fp` test case): 14,274 executions per second **Observations and Considerations** Based on these results: * Ramda appears to be the fastest implementation, with a nearly 4x speedup over the other two options. * The difference between the two Lodash FP implementations is significant (lo vs. lodash fp), indicating potential performance issues due to poor composition or unnecessary intermediate computations. **Other Alternatives** Some alternative libraries that might be used for similar use cases include: 1. **Underscore.js**: A lightweight functional programming library, which was popular before Lodash. 2. **FP-JS**: A more specialized functional programming library with a focus on array and object operations. 3. **JavaScript's built-in `Array.prototype` methods**: While not as feature-rich as the above libraries, the standard JavaScript Array prototype provides various useful methods for data manipulation. Keep in mind that the performance differences between these alternatives may vary depending on your specific use case, library versions, and platform details. Always test and profile your code to ensure optimal performance.
Related benchmarks:
Lodash vs Ramda
Lodash vs Ramda (2020-08 edition)
Lodash vs Ramda 2020-09-01
Lodash vs Ramdasdfsdf
Comments
Confirm delete:
Do you really want to delete benchmark?