Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Ramda vs. Lodash vs. Native array methods
(version: 0)
Comparing performance of:
Lodash vs Ramda compose vs Ramda pipe vs Native
Created:
2 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.25.0/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(50000).map(function(i) { return { counter: i } }); function isOdd({ counter }) { return counter % 2 === 1; } function square({ counter }) { return counter * counter; } function lessThanThreeDigits(value) { return value.toString().length < 3; }
Tests:
Lodash
var result = _.chain(data) .filter(isOdd) .map(square) .filter(lessThanThreeDigits) .value();
Ramda compose
var result = R.compose( R.filter(isOdd), R.map(square), R.filter(lessThanThreeDigits) )(data);
Ramda pipe
var result = R.pipe( R.filter(isOdd), R.map(square), R.filter(lessThanThreeDigits) )(data);
Native
const result = data .filter(isOdd) .map(square) .filter(lessThanThreeDigits);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
Lodash
Ramda compose
Ramda pipe
Native
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 years ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Browser/OS:
Chrome 120 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Lodash
861.5 Ops/sec
Ramda compose
1989.1 Ops/sec
Ramda pipe
791.3 Ops/sec
Native
701.5 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the provided benchmark and explain what's being tested. **Benchmark Overview** The benchmark is comparing the performance of three approaches to process an array of objects: 1. Ramda (a functional programming library) 2. Lodash (another popular utility library for JavaScript) 3. Native JavaScript methods (without using any external libraries) **Test Cases** Each test case has a similar structure, involving filtering, mapping, and another filtering operation on the `data` array. The only difference is in how the operations are chained together: * Ramda: uses `R.compose()` or `R.pipe()`, which apply functions in sequence. * Lodash: uses `_chain()` to chain functions together. * Native JavaScript: uses simple method calls, without any library assistance. **Options Compared** The benchmark compares three options for processing the `data` array: 1. **Ramda**: using functional programming principles with `R.compose()` or `R.pipe()`. 2. **Lodash**: using a more imperative approach with `_chain()`. 3. **Native JavaScript**: using native functions, like array methods and `forEach()`, without any external libraries. **Pros and Cons of Each Approach** Here's a brief summary: * **Ramda (functional programming)**: + Pros: expressive, concise code, can be more efficient due to caching. + Cons: might be less familiar to some developers, additional library dependency. * **Lodash (imperative)**: + Pros: widely used and well-known, easy to read for those familiar with its API. + Cons: might lead to more verbose code, less efficient due to unnecessary operations. * **Native JavaScript**: + Pros: no external dependencies, straightforward code that's easily understandable. + Cons: might be slower or more error-prone without proper caching and optimizations. **Library Usage** The `data` array is processed using two libraries: 1. Ramda (version 0.25.0) 2. Lodash (version 4.17.5) Both libraries are popular utility libraries for JavaScript, providing a range of functions for tasks like array manipulation, string processing, and more. **Special JS Features** There's no specific mention of special JavaScript features or syntax in the benchmark code. It only uses standard JavaScript features, such as arrow functions, template literals, and object methods. **Alternatives** If you're interested in exploring alternative approaches to this benchmark, consider: 1. **Other functional programming libraries**: such as Immutable.js, Svelte, or Vuex. 2. **Alternative utility libraries**: like jQuery (although not recommended for performance-critical applications). 3. **More native JavaScript approaches**: using techniques like memoization, caching, or optimizing array methods. Keep in mind that the choice of approach depends on your specific project requirements, performance needs, and personal preferences as a developer.
Related benchmarks:
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?