Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
ramda vs javascript (improved 3)
(version: 0)
Comparing performance of:
regular javascript vs ramda
Created:
2 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.27.0/ramda.min.js"></script>
Script Preparation code:
var propertyCell = { condition: { field: { comparator: "IS_TIMERANGE", end: [{ value: 1 }] } } }; var data = []; for (var i = 0; i < 100000; i++) { data.push(propertyCell); }
Tests:
regular javascript
const result = new Array(); for (var i = 0; i < data.length; i++) { const array = propertyCell?.condition?.field?.end || []; const propertyValueLast = array[array.length - 1]; const propertyValue = propertyValueLast.value result.push(propertyValue) }
ramda
const result = new Array(); for (var i = 0; i < data.length; i++) { const array = R.pathOr([], ["condition", "field", "end"], propertyCell) const propertyValueLast = array[array.length - 1]; const propertyValue = R.prop("value", propertyValueLast); result.push(propertyValue) }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
regular javascript
ramda
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 years ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36
Browser/OS:
Chrome 122 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
regular javascript
137.0 Ops/sec
ramda
28.9 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the benchmark and explain what's being tested. **Benchmark Overview** The benchmark compares two approaches to access a nested property in JavaScript: 1. **Regular JavaScript**: This approach uses the `propertyCell` object directly, accessing the nested properties using dot notation (e.g., `propertyCell.condition.field.end.value`). 2. **Ramda**: This approach uses the Ramda library, which is a functional programming library for JavaScript. Specifically, it uses the `R.pathOr()` function to access the nested property. **Options Compared** The benchmark compares two options: * Regular JavaScript: This approach relies solely on the native JavaScript syntax and does not use any external libraries. * Ramda: This approach uses the Ramda library, which provides a set of functional programming functions for working with data. **Pros and Cons** Here are some pros and cons of each approach: **Regular JavaScript** Pros: * No dependencies or external libraries required * Simple and familiar syntax Cons: * May be slower due to overhead from accessing nested properties using dot notation * Error handling can be more complex due to the lack of a library to handle errors **Ramda** Pros: * Provides a concise and expressive way to access nested properties using functional programming concepts * Often faster than native JavaScript due to optimized implementations Cons: * Requires an external dependency (the Ramda library) * May require additional setup or configuration for some use cases **Library: Ramda** Ramda is a functional programming library for JavaScript that provides a set of functions for working with data. In this benchmark, the `R.pathOr()` function is used to access the nested property. The purpose of Ramda is to provide a concise and expressive way to work with data in a declarative manner. **Special JS Feature/Syntax** There are no special JavaScript features or syntax being tested in this benchmark. However, it's worth noting that some modern JavaScript versions (e.g., ES6+) have introduced new syntax and features that could affect performance. But in this specific case, the focus is on comparing two approaches to access a nested property. **Alternatives** If you're interested in exploring alternative approaches, here are a few options: * **Lodash**: Another popular functional programming library for JavaScript that provides similar functionality to Ramda. * **Native JavaScript methods**: Some modern browsers and Node.js versions have introduced native methods for accessing nested properties (e.g., `Object.getPrototypeOf()` or `Array.prototype.findIndex()`). These methods may offer better performance than the regular JavaScript approach used in this benchmark. I hope this explanation helps!
Related benchmarks:
Ramda range vs Array.from
ramda vs javascript (improved)
ramda vs javascript (improved 2)
ramda vs javascript (improved 7)
Comments
Confirm delete:
Do you really want to delete benchmark?