Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Ramda vs Lodash sortBy
(version: 0)
Comparing performance of:
Lodash vs ramda
Created:
5 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src="//cdnjs.cloudflare.com/ajax/libs/ramda/0.25.0/ramda.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js"></script>
Script Preparation code:
var users = [{ 'user': 'fred', 'age': 48 }, { 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }, { 'user': 'barney', 'age': 34 } ];
Tests:
Lodash
_.sortBy(users, [function(o) { return o.age; }]);
ramda
const byAge = R.ascend(R.compose(R.prop('age'))); R.sort(byAge, users);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Lodash
ramda
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:132.0) Gecko/20100101 Firefox/132.0
Browser/OS:
Firefox 132 on Mac OS X 10.15
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Lodash
2522298.2 Ops/sec
ramda
715261.9 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the benchmark test. **What is being tested?** The test compares the performance of two JavaScript libraries, Ramda and Lodash, when it comes to sorting an array of objects using the `sortBy` function. Specifically, it tests how long each library takes to sort an array of users based on their age. **Options compared:** The options being compared are: * Ramda's `R.sort` with a custom comparator function created using `R.compose` and `R.prop` * Lodash's `_` (the main object) with the `sortBy` function **Pros and Cons of each approach:** 1. **Ramda:** * Pros: + More concise and expressive code (e.g., using `R.compose` to create a custom comparator) + Potential for better performance due to optimized internal implementations * Cons: + May have a steeper learning curve due to its functional programming style 2. **Lodash:** * Pros: + Well-established and widely-used library with a large community of developers who contribute to it + May be more familiar to developers who are already comfortable with Lodash * Cons: + More verbose code (e.g., needing to use `_` followed by `sortBy`) + May have slower performance due to the need for additional function calls and lookups **Library usage:** Both libraries are used in their respective test cases: 1. Ramda is used with its internal `R.sort` function, which takes an array and a comparator function as arguments. 2. Lodash is used with its `_sortBy` function, which also takes an array and a comparator function (in this case, a simple arrow function). **Special JS features or syntax:** The test uses the following special JavaScript features: 1. **Arrow functions**: Used in both libraries to create simple comparator functions. 2. **Template literals**: Used in the script preparation code to define the `users` array and the HTML preparation code to include the library scripts. **Other considerations:** 1. **Hardware and software variations**: The test is run on a Mac with Chrome 125, which may not be representative of all possible hardware and software configurations. 2. **Network latency and overhead**: The test's results are affected by network latency and overhead, which may impact the actual performance difference between the two libraries in real-world scenarios. **Alternatives:** Other JavaScript libraries that provide similar functionality to Ramda and Lodash include: 1. **Preact**: A lightweight alternative to React for building user interfaces. 2. **Babel**: A popular transpiler for converting modern JavaScript code to older syntaxes. 3. **Immer**: A library for managing state changes in functional applications. Keep in mind that the choice of library often depends on specific requirements, such as performance needs, learning curve preferences, and ecosystem constraints.
Related benchmarks:
sortBy performance1
lodash vs es6 in sort method
native sort of objects by localeCompare vs lodash _.sortBy
order desc with lodash orderBy vs es6 sort method
native sort of objects by linus
Comments
Confirm delete:
Do you really want to delete benchmark?