Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash FP vs Lodash vs Ramda vs Native 2020-12-16
(version: 0)
Tests libraries lodash, ramda and native array functions on a sequence of map, filter, map filter operations.
Comparing performance of:
Ramda (NO Curry) vs Ramda (Curry) vs JavaScript vs Lodash
Created:
5 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.27.1/ramda.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.20/lodash.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; } var MyObject = { description: 'Creates a deep copy of source, which should be an object or an array.', myNumber: 123456789, myBoolean: true, jayson: { stringify: 'JSON.stringify() method converts a JavaScript value to a JSON string....', parse: 'JSON.parse() method parses a JSON string...' }, array: [ { stringify: 'one string....', parse: 'two string...' }, { stringify: 'three string....', parse: 'four string...' }, { stringify: 'five string....', parse: 'six string...' }, ] }; var myCopy = null; var arr = new Array(Number.MAX_SAVE_INTEGER).fill(null); var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]; var isOddTwo = n => n % 2 === 1;
Tests:
Ramda (NO Curry)
var result = R.filter( lessThanThreeDigits, R.map( square, R.filter( isOdd, R.pluck('counter', data), ), ), ); myCopy = R.clone(MyObject); R.map(x => x * 10, arr); R.pipe(R.map(R.inc), R.filter(isOddTwo), R.take(5), R.last);
Ramda (Curry)
var result = R.pipe( R.pluck('counter'), R.filter(isOdd), R.map(square), R.filter(lessThanThreeDigits) )(data);
JavaScript
var result = data .map(x => x.counter) .filter(isOdd) .map(square) .filter(lessThanThreeDigits) ; myCopy = JSON.parse(JSON.stringify(MyObject)); arr.map(x => x * 10);
Lodash
var result = _.chain(data) .pick('counter') .filter(isOdd) .map(square) .filter(lessThanThreeDigits) .value(); myCopy = _.cloneDeep(MyObject); _.map(arr, x => x * 10); _.flow(_.map(x => x + 1), _.filter(isOdd), _.take(5), _.last);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
Ramda (NO Curry)
Ramda (Curry)
JavaScript
Lodash
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):
I'll break down the benchmark test and its various components. **Benchmark Test Overview** The benchmark test compares the performance of four different libraries: Lodash, Ramda, native JavaScript functions, and no library (i.e., vanilla JavaScript). The test focuses on three operations: 1. Filtering and mapping a dataset. 2. Cloning an object. 3. Performing array transformations. **Individual Test Cases** Each test case represents a distinct scenario that showcases the strengths and weaknesses of each library. Here's a brief explanation of each test case: 1. **Ramda (NO Curry)**: This test case uses Ramda's non-curried functions to perform filtering, mapping, and transformation operations on the dataset. 2. **Ramda (Curry)**: Similar to the previous test case, but this time using curried functions from Ramda. 3. **JavaScript**: This test case uses native JavaScript functions for all operations, demonstrating the performance of vanilla JavaScript without any library support. 4. **Lodash**: This test case utilizes Lodash's functions for filtering, mapping, and cloning, showcasing its capabilities. **Libraries and Their Purposes** * **Ramda**: A functional programming library that provides a set of higher-order functions (curried or non-curried) to manipulate data. Ramda is designed to be lightweight and efficient. * **Lodash**: Another popular JavaScript utility library that offers a wide range of functions for tasks like filtering, mapping, cloning, and more. Lodash's API can be more verbose than Ramda's. **Pros and Cons** Each library has its strengths and weaknesses: * **Ramda**: + Pros: Lightweight, concise API, efficient performance. + Cons: May require additional setup or understanding of curried functions. * **Lodash**: + Pros: Comprehensive set of utility functions, easy to use for many developers. + Cons: Larger bundle size compared to Ramda, potentially slower performance due to the overhead. **Special JavaScript Features** None are explicitly mentioned in this benchmark test. However, it's worth noting that modern JavaScript features like async/await, Promises, and ES6/ES7 syntax enhancements can impact performance and coding style. **Alternative Implementations** Other alternative implementations for similar tasks could include: * **Underscore.js**: A utility library similar to Lodash but with a smaller footprint. * **Mocha**: A popular testing framework for JavaScript that might be used in conjunction with other libraries or native functions. * **Native V8 Engine**: The built-in engine of the Node.js runtime, which can be used directly without any external libraries. **Benchmark Results** The provided benchmark results show the performance differences between each library and native JavaScript. These values are specific to Firefox 105 on Windows and should not be considered representative of all users or use cases. Keep in mind that these tests demonstrate specific aspects of library usage, but may not capture the full scope of their capabilities or edge cases. In real-world applications, developers must consider factors like code readability, maintainability, and performance when choosing a library for their project.
Related benchmarks:
Map (Native vs Ramda vs Lodash) latest 2021-01-18
lodash mapValues vs vanilla Object.keys foreach vs lodash reduce
Map (Native vs Ramda 0.27.2 vs Lodash 4.17.21) 50k
Last element (Native vs Ramda vs Lodash)
Comments
Confirm delete:
Do you really want to delete benchmark?