Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash vs Ramda vs Underscore 1.9.0 - IE11 Compatible
(version: 0)
Comparing performance of:
Lodash vs Ramda without relying on currying or composition vs Ramda with currying and composition vs Underscore
Created:
7 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.9.0/underscore.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(function(m) {return m.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(function(item) {return 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):
**Overview of the Benchmark** The provided JSON represents a JavaScript benchmark that compares the performance of three functional programming libraries: Lodash, Ramda, and Underscore (version 1.9.0). The benchmark focuses on processing an array of 10,000 objects with specific properties. **Options Compared** The benchmark compares four different approaches: 1. **Lodash**: Uses `_.chain()` to create a pipeline of operations. 2. **Ramda without currying or composition**: Utilizes `R.filter()`, `R.map()`, and `R.pluck()` functions directly. 3. **Ramda with currying and composition**: Employs `R.pipe()` to compose functions together. 4. **Underscore**: Leverages `_chain()` to create a pipeline of operations. **Pros and Cons of Each Approach** 1. **Lodash**: * Pros: Easy to read and understand, familiar syntax for Lodash users. * Cons: May be less performant due to the overhead of `_.chain()`. 2. **Ramda without currying or composition**: * Pros: Can be more efficient since it avoids function creation and composition. * Cons: Requires a good understanding of Ramda's API and may lead to harder-to-read code. 3. **Ramda with currying and composition**: * Pros: Can produce optimized, inline code for better performance. * Cons: Steeper learning curve due to the use of `R.pipe()` and functional programming concepts. 4. **Underscore**: * Pros: Similar syntax to Lodash, making it easy to read and understand. * Cons: May have similar performance characteristics as Lodash. **Library Usage** 1. **Lodash**: Uses `_chain()`, `map()`, `filter()`, and other utility functions. 2. **Ramda**: Utilizes `R.filter()`, `R.map()`, `R.pluck()`, `R.pipe()` (with currying), and other functional programming tools. 3. **Underscore**: Employs `_chain()`, `map()`, `filter()`, and other utility functions. **Special JavaScript Features/Syntax** The benchmark does not explicitly use any special JavaScript features or syntax, but it is worth noting that the use of functional programming libraries like Ramda can be beneficial for writing concise, expressive code. **Alternative Approaches** Other alternatives to consider when working with large datasets: 1. **ES6+ methods**: Utilize built-in array methods like `forEach()`, `map()`, and `filter()` for simple operations. 2. **Custom solution**: Write a custom loop-based implementation for optimal performance, but this may lead to more complex code. **Benchmarking Best Practices** To improve the benchmark: 1. Increase dataset size to better represent real-world scenarios. 2. Experiment with different data distributions (e.g., random numbers). 3. Add additional operations or complexity to the benchmark. 4. Use multiple execution configurations (e.g., CPU, GPU) for fair comparison. Keep in mind that benchmarks are always a good starting point, but they should be taken as rough estimates rather than definitive measures of performance.
Related benchmarks:
Lodash vs Ramda vs Underscore 1.9.0 - IE11 Compatible with vanilla
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?