Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
ramda vs javascript (improved 7)
(version: 0)
Comparing performance of:
ramda vs regular javascript
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 }] } } };
Tests:
ramda
const result = new Array(); for (var i = 0; i < 100000; i++) { const array = propertyCell?.condition?.field?.end || []; const propertyValueLast = array[array.length - 1]; const propertyValue = R.prop("value", propertyValueLast); result.push(propertyValue) }
regular javascript
const result = new Array(); for (var i = 0; i < 100000; i++) { const array = propertyCell?.condition?.field?.end || []; const propertyValueLast = array[array.length - 1]; const propertyValue = propertyValueLast.value result.push(propertyValue) }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
ramda
regular javascript
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
ramda
70.0 Ops/sec
regular javascript
248.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
**Benchmark Overview** MeasureThat.net is a website that allows users to create and run JavaScript microbenchmarks. The provided benchmark definition involves comparing the performance of two approaches: Ramda, a functional programming library, and regular JavaScript. **Script Preparation Code** The script preparation code defines an object `propertyCell` with nested properties: ```javascript var propertyCell = { condition: { field: { comparator: "IS_TIMERANGE", end: [{ value: 1 }] } } }; ``` This object is used as a data source for the benchmark tests. **Html Preparation Code** The HTML preparation code includes a script tag that loads the Ramda library: ```html <script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.27.0/ramda.min.js"></script> ``` This ensures that the Ramda library is available for use in the benchmark tests. **Individual Test Cases** There are two test cases: 1. **Ramda**: ```javascript const result = new Array(); for (var i = 0; i < 100000; i++) { const array = propertyCell?.condition?.field?.end || []; const propertyValueLast = array[array.length - 1]; const propertyValue = R.prop("value", propertyValueLast); result.push(propertyValue) } ``` This test case uses the Ramda library to access the `value` property of the last element in the `end` array. 2. **Regular JavaScript**: ```javascript const result = new Array(); for (var i = 0; i < 100000; i++) { const array = propertyCell?.condition?.field?.end || []; const propertyValueLast = array[array.length - 1]; const propertyValue = propertyValueLast.value; result.push(propertyValue) } ``` This test case uses regular JavaScript to access the `value` property of the last element in the `end` array. **Pros and Cons** The two approaches have different pros and cons: * **Ramda**: + Pros: Encapsulates complex logic in a reusable function, reduces boilerplate code. + Cons: May introduce overhead due to the library's functionality, can be slower for simple operations. * **Regular JavaScript**: + Pros: Fast and lightweight, no dependencies, easy to understand. + Cons: More verbose, requires explicit type checks, may lead to errors. **Library: Ramda** Ramda is a functional programming library that provides a set of higher-order functions for working with data. The `R.prop` function in the benchmark test case uses Ramda's API to access the `value` property of an object. **Other Alternatives** If you prefer not to use Ramda, you can implement the same functionality using regular JavaScript or other functional programming libraries like Lodash or jQuery. Here is an example of how you could rewrite the Ramda test case using only built-in JavaScript functions: ```javascript const result = new Array(); for (var i = 0; i < 100000; i++) { const array = propertyCell?.condition?.field?.end || []; const propertyValueLast = array[array.length - 1]; const propertyValue = propertyValueLast && propertyValueLast.value; result.push(propertyValue) } ``` Keep in mind that this implementation may be slower and more prone to errors than the Ramda version.
Related benchmarks:
ramda vs javascript (improved)
ramda vs javascript (improved 2)
ramda vs javascript (improved 3)
ramda vs javascript (improved 10)
Comments
Confirm delete:
Do you really want to delete benchmark?