Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash vs rama vs pure
(version: 0)
Comparing performance of:
ramda vs lodash vs pure vs pure 2
Created:
6 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.26.1/ramda.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.15/lodash.min.js"></script>
Script Preparation code:
var data = {x: {y:'something', z: 'somethingElse'}, a: {c: 'whatyp'}};
Tests:
ramda
let result = R.compose( R.assocPath(['a', 'b'], 'bye-world'), R.assocPath(['x', 'y'], 'hello-world') )(data);
lodash
let result = _.chain(data) .set(['x', 'y'], 'hello-world') .set(['a', 'b'], 'bye-world')
pure
let result = { ...data, x: { ...data.x, y: 'hello-world' }, a: { ...data.a, b: 'bye-world' } }
pure 2
data.x.y = 'hello-world' data.a.b = 'bye-world' let result = data;
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
ramda
lodash
pure
pure 2
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'd be happy to help you understand the JavaScript benchmark provided by MeasureThat.net. **Overview** The benchmark compares the performance of three different approaches for updating an object: Lodash, Ramda, and a pure object update method. **Script Preparation Code** The script preparation code provides a sample data object that will be used as input for the benchmark: ```javascript var data = {x: {y:'something', z: 'somethingElse'}, a: {c: 'whatyp'}} ``` This object has two nested properties: `x` and `a`, each with their own nested properties. **Html Preparation Code** The html preparation code includes two external JavaScript libraries: * Lodash (version 4.17.15): `https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.15/lodash.min.js` * Ramda (version 0.26.1): `https://cdnjs.cloudflare.com/ajax/libs/ramda/0.26.1/ramda.min.js` These libraries provide functional programming utilities and functions, respectively. **Individual Test Cases** There are four test cases: 1. **Ramda**: The benchmark definition uses Ramda's `R` namespace to update the object using `R.assocPath(['a', 'b'], 'bye-world')` and then again with `R.assocPath(['x', 'y'], 'hello-world')`. 2. **Lodash**: The benchmark definition uses Lodash's `_` alias to update the object using `.chain(data) .set(['x', 'y'], 'hello-world') .set(['a', 'b'], 'bye-world')`. 3. **Pure**: The first test case uses a pure object update method, which simply creates a new object with updated properties: `{ ...data, x: { ...data.x, y: 'hello-world' }, a: { ...data.a, b: 'bye-world' } }`. 4. **Pure 2**: This is another test case using the same pure object update method as above. **Benchmark Results** The latest benchmark results show the performance of each approach for each test case: * Chrome 80 on Windows Desktop: + Pure 2: 703,583 executions per second + Pure: 612,628 executions per second + Lodash: 361,113 executions per second + Ramda: 894,523 executions per second **Pros and Cons** Here's a brief summary of the pros and cons of each approach: * **Pure**: Pros: + Simple and intuitive implementation. + Fast execution time. Cons: + Creates a new object with updated properties. * **Lodash**: Pros: + Provides additional functionality beyond pure object updates (e.g., chaining, mapping). Cons: + More complex implementation compared to the pure approach. + Slightly slower execution time. * **Ramda**: Pros: + Provides functional programming utilities and a more concise implementation. Cons: + Less familiar interface for those not using Ramda. **Library Descriptions** Both Lodash and Ramda provide functional programming utilities and functions that can be used to update objects. These libraries offer benefits such as: * Chaining: allowing multiple operations to be performed in sequence without creating a new object at each step. * Mapping: applying a function to each property of an object. **Special JS Features or Syntax** There are no special JavaScript features or syntax used in this benchmark that would require prior knowledge or expertise. The focus is on comparing the performance of three different approaches for updating objects, using familiar libraries and concepts.
Related benchmarks:
Ramda vs Lodash vs Native : Remove selected values
Native Object.values().some() vs lodash _.some()
Lodash vs Ramda vs Native fromPairs
lodash isstring vs typeof
Comments
Confirm delete:
Do you really want to delete benchmark?