Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Test set
(version: 7)
Comparing performance of:
Ramda vs Immutable
Created:
7 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src="https://unpkg.com/ramda@0.25.0/dist/ramda.min.js"></script> <script src="https://unpkg.com/lodash@4.17.10/lodash.js"></script> <script src="https://unpkg.com/immutable@4.0.0-rc.9/dist/immutable.js"></script>
Script Preparation code:
var data = R.indexBy(() => 'id', _.range(10000).map(n => ({id: n, title: 'test ' + n}))); var immutableData = Immutable.Map(data); console.log(data, immutableData);
Tests:
Ramda
var result = R.assoc('1001', 'changed title', data)['1001']; console.log(result);
Immutable
var result = immutableData.set('1001', 'changed title').get('1001'); console.log(result);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Ramda
Immutable
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):
Let's break down the provided JSON and explain what's being tested. **Benchmark Definition** The `Script Preparation Code` section provides code that sets up the data for the benchmark: ```javascript var data = R.indexBy(() => 'id', _.range(10000).map(n => ({id: n, title: 'test ' + n}))); var immutableData = Immutable.Map(data); console.log(data, immutableData); ``` Here's what's happening: 1. `_.range(10000)`: Creates an array of 10,000 numbers from 0 to 9,999. 2. `.map(n => ({id: n, title: 'test ' + n}))`: Maps each number in the range to an object with two properties: `id` and `title`. The `title` property is set to a string that concatenates "test " with the current number. 3. `R.indexBy(() => 'id', ...)`: Uses the Ramda library to create a new array where each element is an object with `id` as its key. This essentially maps each object in the previous step to an object with only one property: `id`. 4. `Immutable.Map(data)`: Converts the resulting array into an Immutable Map, which is an immutable data structure. The `Html Preparation Code` section includes links to external libraries: * Ramda * Lodash * Immutable.js **Individual Test Cases** There are two test cases defined in the `Benchmark Definition` JSON: 1. "Ramda" ```javascript var result = R.assoc('1001', 'changed title', data)['1001']; console.log(result); ``` This code uses Ramda's `assoc` function to find the value associated with key `'1001'` in the `data` object. The resulting value is then logged to the console. 2. "Immutable" ```javascript var result = immutableData.set('1001', 'changed title').get('1001'); console.log(result); ``` This code uses Immutable.js's `set` function to update the `immutableData` Map with a new value for key `'1001'`. The updated value is then retrieved using the `get` function and logged to the console. **Benchmark Results** The latest benchmark results show that: * Chrome 71 on Windows Desktop, running at an average of 82130.5390625 executions per second * Chrome 71 on Windows Desktop, running at an average of 50243.69140625 executions per second These results indicate the relative performance of Ramda and Immutable.js when executing these two specific benchmark tests. **Libraries Used** 1. **Ramda**: A functional programming library for JavaScript that provides a concise way to manipulate data. 2. **Lodash**: A utility library that provides a lot of common functions, including some used in this benchmark (e.g., `_.range`). 3. **Immutable.js**: An immutable data structure library that provides efficient and thread-safe updates. **Special JS Feature/Syntax** None mentioned explicitly, but note that Ramda uses functional programming concepts like map, filter, and reduce, which are different from the imperative approach used in traditional JavaScript. **Alternatives** Some alternatives to Ramda and Immutable.js include: * **Underscore.js**: Another utility library that provides a lot of common functions for working with data. * **Soy**: A library for functional programming and data manipulation in JavaScript. * **Clojure.js**: A JavaScript port of the Clojure programming language, which also includes libraries like Ramda. These alternatives can be used as substitutes or complements to Ramda and Immutable.js, depending on specific use cases and requirements.
Related benchmarks:
Map (Native vs Ramda vs Lodash vs Immutable) - sample size 100 1
immutable vs lodash vs ...
immutable vs lodash vs ... 4
immutable vs lodash vs ... 5
Comments
Confirm delete:
Do you really want to delete benchmark?