Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Ramda forEachObjIndexed vs Native Object.values + Array.map
(version: 0)
Comparing performance of:
Ramda (while loop inside) vs Native ES5 Object.values + Array.map
Created:
5 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<html> <head> <script src='https://cdnjs.cloudflare.com/ajax/libs/ramda/0.27.1/ramda.min.js'></script> </head> <body></body> </html>
Script Preparation code:
window.testData = {} for (i = 0; i < 10000; i++) { window.testData['key' + i] = i }
Tests:
Ramda (while loop inside)
R.forEachObjIndexed((value, key) => console.log(value), window.testData)
Native ES5 Object.values + Array.map
Object.values(window.testData).map(value => console.log(value))
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Ramda (while loop inside)
Native ES5 Object.values + Array.map
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 explain the benchmark and its results. **Benchmark Overview** The benchmark compares the performance of two approaches: 1. **Ramda `forEachObjIndexed`**: This method is part of the Ramda library, which provides a functional programming style for JavaScript. It iterates over an object's keys and values simultaneously. 2. **Native ES5 `Object.values + Array.map`**: This approach uses native JavaScript methods to extract values from an object and log them in an array. **Benchmark Definition JSON** The benchmark definition JSON contains the following information: * **Name**: The name of the benchmark, which is "Ramda forEachObjIndexed vs Native Object.values + Array.map". * **Description**: An empty string indicating that there's no description for this benchmark. * **Script Preparation Code**: A script that creates a `window.testData` object with 10,000 key-value pairs, where each value is the corresponding key incremented by 1. * **Html Preparation Code**: An HTML snippet that includes a script tag to load the Ramda library. **Individual Test Cases** The benchmark consists of two individual test cases: 1. **Ramda (while loop inside)**: This test case uses the `forEachObjIndexed` method from Ramda, which iterates over an object's keys and values simultaneously using a while loop. 2. **Native ES5 Object.values + Array.map**: This test case uses native JavaScript methods to extract values from the `window.testData` object and log them in an array using `Object.values` and `Array.map`. **Library Used** In this benchmark, Ramda is used as a library for providing the functional programming style and `forEachObjIndexed` method. **Special JS Feature/Syntax** There are no special JavaScript features or syntax mentioned in this benchmark. The code uses standard ES5 syntax and relies on native JavaScript methods. **Benchmark Results** The latest benchmark result contains two test cases, each with a different approach: 1. **Ramda (while loop inside)**: This test case shows the performance of using Ramda's `forEachObjIndexed` method with a while loop. 2. **Native ES5 Object.values + Array.map**: This test case shows the performance of using native JavaScript methods to extract values from an object and log them in an array. The results indicate that the native ES5 approach outperforms the Ramda approach. **Other Alternatives** Some other alternatives for this benchmark could be: * Using `Array.prototype.forEach` instead of `forEachObjIndexed` * Using a different library, such as Lodash or Jest * Using a different programming paradigm, such as imperative or parallel processing However, it's worth noting that the choice of approach depends on the specific use case and requirements. For example, if you need to perform operations on objects with complex data structures, Ramda's functional programming style might be more suitable. In summary, this benchmark compares the performance of two approaches for iterating over an object's values: Ramda's `forEachObjIndexed` method and native ES5 methods (`Object.values + Array.map`). The benchmark results show that the native ES5 approach outperforms the Ramda approach.
Related benchmarks:
map vs forEach Chris v2b
_.forIn vs for in
lodash mapValues vs vanilla Object.keys foreach vs lodash reduce
For in vs Object.*.forEach vs Object.values vs _.forEach(_.values v3
For in vs Object.*.forEach vs Object.values vs _.forEach(_.values vs n=arr.length
Comments
Confirm delete:
Do you really want to delete benchmark?