Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash vs Ramda 0.26.1 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:
6 years ago
by:
Guest
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://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(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):
The provided JSON represents a JavaScript benchmark test case, which compares the performance of three libraries: Lodash, Ramda, and Underscore. **Benchmarked operations** The benchmark tests four distinct operations: 1. `filter(isOdd)`: This operation filters an array to include only elements that are odd numbers. 2. `map(square)`: This operation maps each element in an array to its square value. 3. `filter(lessThanThreeDigits)`: This operation filters an array to include only elements with fewer than three digits. These operations are combined in different ways for each library, which is described below. **Library-specific details** 1. **Lodash**: Lodash is a popular utility library that provides a wide range of functions for tasks like filtering, mapping, and transforming arrays. 2. **Ramda**: Ramda is another functional programming library that provides a set of higher-order functions for manipulating arrays and objects. 3. **Underscore.js**: Underscore.js is a minimalist utility library that provides a smaller set of functions compared to Lodash. **Currying and composition** Ramda uses two different approaches to these operations: * "without relying on currying or composition" uses the `R.filter`, `R.map`, and `R.pluck` functions directly. * "with currying and composition" uses a pipeline-like approach with `R.pipe`, which applies multiple functions in sequence. In contrast, Lodash and Underscore.js use more traditional, imperative-style approaches to these operations. **Pros and cons of each approach** 1. **Lodash**: Pros: * Familiar, intuitive API for many developers. * Wide range of useful functions. Cons: * Can be slower than Ramda due to the overhead of function calls. 2. **Ramda**: Pros: * More concise and expressive API for functional programming tasks. * Built-in support for currying and composition can lead to more efficient code. Cons: * Steeper learning curve for developers unfamiliar with functional programming concepts. 3. **Underscore.js**: Pros: * Smaller, faster footprint compared to Lodash. * Simple, concise API. Cons: * Fewer useful functions than Lodash. **Other considerations** 1. **Optimization techniques**: The benchmark may not cover all possible optimization techniques, such as caching or memoization. Developers should consider applying these techniques when working with these libraries in production code. 2. **Environment and hardware variations**: The results of this benchmark might vary depending on the environment (e.g., Node.js version, browser) and hardware (e.g., CPU architecture, RAM). Developers should test their code on various platforms to ensure it performs well. In summary, this benchmark helps developers understand the performance differences between Lodash, Ramda, and Underscore.js when performing common array operations. By considering the pros and cons of each library's approach and optimizations techniques, developers can make informed decisions about which library best suits their project needs.
Related benchmarks:
Lodash vs Ramda vs Underscore 1.9.0 vs native
Lodash vs Ramda vs Underscore 1.5.2
Lodash vs Ramda (2020-08 edition)
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?