Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Ramda vs Lodash FP composed map filter sortBy
(version: 2)
Comparing performance of:
Ramda vs Lodash
Created:
7 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/ramda@0.26.1/dist/ramda.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/lodash@4.17.11/lodash.fp.min.js"></script>
Script Preparation code:
// var array = Array(100).fill().map(Math.random); var array = [0.9017467706848585,0.21272564120328719,0.6962267619498075,0.6422277838711532,0.9593646394969273,0.384545707843011,0.9621549107377982,0.3310154380805628,0.5888331288848434,0.6021934672232572,0.3867214245632906,0.44002551285037295,0.7844416925009745,0.4683798326064532,0.09530742807118653,0.9494980110682019,0.5517627476737859,0.27075531846293566,0.6368142865072488,0.09941470583217682,0.933486501012984,0.4985221065955707,0.41904389585011526,0.923596140305686,0.5228002084782135,0.6077779467188327,0.42320840902905843,0.731232440539773,0.9307780531862417,0.29836024021648444,0.554579757093159,0.4053992807493627,0.16091630002749158,0.7705124075175338,0.9608223557179418,0.4394781888577608,0.01095432401863472,0.03136616679676041,0.6997676761412202,0.8588471864228564,0.8832188299348112,0.30846541709664077,0.36841129639164527,0.6844774184833411,0.9170193800972171,0.8570589565501101,0.9903224465308713,0.46032265724049126,0.5709604148146583,0.0001866705452648887,0.5168371304925241,0.13473327748744635,0.5859259608223231,0.5700380981079469,0.9893382756645077,0.9439062611356868,0.25842777584107135,0.5175197385104873,0.8277673822532123,0.16940444558441392,0.9629376000774428,0.7036197679062814,0.05362073290108893,0.011749950514384988,0.461644467239795,0.5679559578600983,0.005852925686180566,0.25155196362153487,0.23808044097825154,0.7301283807008514,0.4721677297582094,0.8140865649653599,0.4171062433916495,0.7387615337866364,0.2049969302657242,0.8503063101238413,0.6927389337217917,0.5935962195783708,0.6749398160799638,0.5016852297473815,0.5741557769313446,0.48198287652961147,0.1864714353069341,0.3902550000789753,0.6095121876925051,0.45837885640334997,0.3455932965299935,0.6084466832174058,0.26804226969749556,0.7079598206946047,0.8858262390845866,0.16575163490735023,0.6046967890110588,0.7853141397533452,0.6680692400578638,0.6944725307476995,0.9711447815982044,0.3973398417805829,0.8772853006110772,0.9056997760024414];
Tests:
Ramda
R.pipe( R.map(Math.round), R.sortBy(val => val), R.filter(Boolean) )(array);
Lodash
_.flow( _.map(Math.round), _.sortBy(val => val), _.filter(Boolean) )(array);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Ramda
Lodash
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):
Taking a deep breath... Measuring performance is a crucial aspect of software development, and MeasuringThat.net provides an excellent platform for benchmarking JavaScript code. The provided JSON represents two test cases: 1. **Ramda vs Lodash FP composed map filter sortBy**: This benchmark tests the performance of using Ramda's `R.pipe` function versus Lodash's `_flow` function to perform a series of operations on an array: * `Math.round`: rounding each element in the array to the nearest integer * `sortBy(val => val)`: sorting the array based on the values in each element * `filter(Boolean)`: filtering out falsy values from the sorted array The benchmark uses a random array of 100 elements and measures the execution time for both Ramda and Lodash. **Options compared:** * **Ramda**: Uses `R.pipe` to chain together the operations, which can be beneficial for performance since it avoids creating temporary intermediate arrays. * **Lodash**: Uses `_flow`, which is similar to `R.pipe` but has some differences in syntax and behavior. `_flow` also returns a new array with the filtered results. **Pros and Cons:** * **Ramda**: + Pros: More concise syntax, potentially better performance due to avoiding temporary arrays. + Cons: May be less readable for developers unfamiliar with Ramda's syntax. * **Lodash**: + Pros: More familiar syntax for developers, wider community support, and more extensive documentation. + Cons: Potentially slower performance compared to Ramda due to creating intermediate arrays. **Library descriptions:** * **Ramda**: A functional programming library for JavaScript that provides a comprehensive set of functions for data processing, manipulation, and transformation. Its `R.pipe` function is particularly useful for chaining operations together. * **Lodash**: A utility-first library that provides a wide range of functions for common tasks such as array manipulation, object inspection, and string manipulation. Its `_flow` function is similar to Ramda's `R.pipe` but with some key differences. **Special JS feature:** There are no special JavaScript features or syntax mentioned in the benchmark definition. The focus is solely on comparing the performance of two libraries' functions. **Alternative approaches:** If you're interested in exploring alternative approaches, here are a few options: * **Using vanilla JavaScript**: You can implement the same operations using only built-in JavaScript functions, such as `map()`, `sort()`, and `filter()`. * **Other functional programming libraries**: You might consider using other libraries like Underscore.js or Saddle.js, which also provide functional programming utilities. * **Caching or memoization**: Depending on the specific use case, caching or memoization could potentially improve performance by avoiding redundant computations. I hope this helps you understand the benchmark!
Related benchmarks:
Lodash FP vs. Ramda
Lodash FP vs. Ramda (fork)
Lodash => (Equal + sort) vs (xor): unsorted array
Ramda sort vs JS native sort vs Lodash
Comments
Confirm delete:
Do you really want to delete benchmark?