Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash vs Ramda vs Underscore 1.9.0
(version: 0)
Comparing performance of:
Lodash vs Ramda without relying on currying or composition vs Ramda with currying and composition vs Underscore
Created:
8 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.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.js"></script> <script type="text/javascript"> window.lodash = _; _ = null; </script> <script src='https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-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:
Lodash
var result = lodash.chain(data) .map(item => item.counter) .filter(isOdd) .map(square) .filter(lessThanThreeDigits) .value();
Ramda without relying on currying or composition
var result = R.filter(lessThanThreeDigits, R.map(square, R.filter(isOdd, R.pluck('counter', data))));
Ramda with currying and composition
var result = R.pipe( R.pluck('counter'), R.filter(isOdd), R.map(square), R.filter(lessThanThreeDigits) )(data);
Underscore
var result = _.chain(data) .map(item => item.counter) .filter(isOdd) .map(square) .filter(lessThanThreeDigits) .value();
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
Lodash
Ramda without relying on currying or composition
Ramda with currying and composition
Underscore
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):
Let's dive into the benchmark definition and explain what is being tested. **Benchmark Definition** The benchmark is testing the performance of three popular JavaScript libraries: Lodash, Ramda, and Underscore.js (version 1.9.0). The test case is designed to measure the execution speed of a specific data processing pipeline using each library. **Test Case Breakdown** Each test case is defined by a `Benchmark Definition` string that outlines the steps involved in processing the data: 1. **Lodash**: `var result = lodash.chain(data) ...` * Uses the `lodash.chain()` method to create a chain of functions, allowing for a more functional programming style. 2. **Ramda without currying or composition**: `var result = R.filter(lessThanThreeDigits, R.map(square, R.filter(isOdd, data)))` * Uses Ramda's functional programming style, but doesn't utilize its currying and composition features. 3. **Ramda with currying and composition**: `var result = R.pipe(R.pluck('counter'), R.filter(isOdd), R.map(square), R.filter(lessThanThreeDigits))(data)` * Utilizes Ramda's curryng and composition features to create a pipeline of functions. 4. **Underscore**: `var result = _.chain(data) ...` * Uses the `_.chain()` method, similar to Lodash. **Library Purpose** 1. **Lodash**: A utility library providing functional programming helpers, such as `chain()`, `map()`, and `filter()`. 2. **Ramda**: A functional programming library providing a pipeline of functions using `R.pipe()` or currying with `R.curry()`. 3. **Underscore.js**: A minimalist utility library providing functional programming helpers, such as `chain()`. **Special JS Features** * Currying: Ramda's `R.curry()` function allows for partial application of a function, creating a new function with a specific number of arguments. * Composition: Ramda's `R.pipe()` function allows for combining multiple functions into a single pipeline. **Other Alternatives** If you're interested in exploring other JavaScript libraries or alternatives: 1. **Mocha**: A popular testing framework that can be used to create more complex benchmarks. 2. **Benchmarking libraries like benchmark.js or fast-benchmark**: Specialized libraries designed specifically for creating high-performance benchmarks. **Pros and Cons** Each library has its strengths and weaknesses: * **Lodash**: + Pros: Easy to use, comprehensive utility library. + Cons: Can be bulky, less efficient than other options. * **Ramda**: + Pros: Functional programming style, powerful composition features. + Cons: Steeper learning curve, more verbose code. * **Underscore.js**: + Pros: Lightweight, easy to use. + Cons: Less comprehensive utility library compared to Lodash or Ramda. Keep in mind that this is just a brief overview of the benchmark definition and libraries involved.
Related benchmarks:
Lodash vs Ramda vs Underscore 1.9.0 - IE11 Compatible
Lodash vs Ramda vs Underscore 1.9.0 vs native
Lodash vs Ramda vs Underscore 1.5.2
Ramda(0.27.0) vs. Lodash(4.17.20) vs Natice (filter, find)
Ramda vs lodash latest
Comments
Confirm delete:
Do you really want to delete benchmark?