Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
ramda vs native pipe
(version: 0)
Comparing performance of:
native vs ramda
Created:
5 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:
const SERVING_TYPE_QUESTION_ID = "f2da9c29-c721-4767-b8e6-291e0e9ffbf5"; const questionCollection = [ { benefitName: "benefit 1", additonalQuestions: [ "f2da9c29-c721-4767-b8e6-291e0e9ffbf5", "b017dd0d-d81c-4d19-93d8-a5170d18940d" ] }, { benefitName: "benefit 2", additonalQuestions: [ "f2da9c29-c721-4767-b8e6-291e0e9ffbf5", "b017dd0d-d81c-4d19-93d8-a5170d18940d" ] }, { benefitName: "benefit 3", additonalQuestions: [ "f2da9c29-c721-4767-b8e6-291e0e9ffbf5", "b017dd0d-d81c-4d19-93d8-a5170d18940d", "32as2139-s132-6523-cyt3-092fgf9d39s9" ] } ];
Tests:
native
const SERVING_TYPE_QUESTION_ID = "f2da9c29-c721-4767-b8e6-291e0e9ffbf5"; const questionCollection = [ { benefitName: "benefit 1", additonalQuestions: [ "f2da9c29-c721-4767-b8e6-291e0e9ffbf5", "b017dd0d-d81c-4d19-93d8-a5170d18940d" ] }, { benefitName: "benefit 2", additonalQuestions: [ "f2da9c29-c721-4767-b8e6-291e0e9ffbf5", "b017dd0d-d81c-4d19-93d8-a5170d18940d" ] }, { benefitName: "benefit 3", additonalQuestions: [ "f2da9c29-c721-4767-b8e6-291e0e9ffbf5", "b017dd0d-d81c-4d19-93d8-a5170d18940d", "32as2139-s132-6523-cyt3-092fgf9d39s9" ] } ];const removeServ = questionCollection.map(category => { const additionalQuestions = category.additonalQuestions.filter(questionID => { return questionID !== SERVING_TYPE_QUESTION_ID; }); return { benefitName: category.benefitName, additionalQuestions: additionalQuestions }; });
ramda
const SERVING_TYPE_QUESTION_ID = "f2da9c29-c721-4767-b8e6-291e0e9ffbf5"; const questionCollection = [ { benefitName: "benefit 1", additonalQuestions: [ "f2da9c29-c721-4767-b8e6-291e0e9ffbf5", "b017dd0d-d81c-4d19-93d8-a5170d18940d" ] }, { benefitName: "benefit 2", additonalQuestions: [ "f2da9c29-c721-4767-b8e6-291e0e9ffbf5", "b017dd0d-d81c-4d19-93d8-a5170d18940d" ] }, { benefitName: "benefit 3", additonalQuestions: [ "f2da9c29-c721-4767-b8e6-291e0e9ffbf5", "b017dd0d-d81c-4d19-93d8-a5170d18940d", "32as2139-s132-6523-cyt3-092fgf9d39s9" ] } ]; const filteredObject = R.map( R.pipe( R.over( R.lensProp("additonalQuestions"), R.reject(R.equals(SERVING_TYPE_QUESTION_ID)) ) ), questionCollection );
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
native
ramda
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 dive into the world of JavaScript microbenchmarks and explore what's being tested in this specific benchmark. **Benchmark Overview** The benchmark compares two approaches: using native JavaScript pipes (in this case, using the `map()` method) versus using the Ramda library's `R.map()` function. The benchmark measures which approach is faster for filtering out a specific value from an array of objects. **Test Case Explanation** Each test case consists of a single "Benchmark Definition" that defines the input data and the expected filtering operation. In this case, the input data is an array of objects with a nested `additonalQuestions` property. The filtering operation is to remove any questions that have a specific ID (`SERVING_TYPE_QUESTION_ID`) from the `additonalQuestions` array. **Native JavaScript Pipe** The native JavaScript pipe uses the `map()` method, which applies a function to each element in the array and returns a new array with the transformed elements. In this case, the filtering operation is done by creating a filter function that checks if the current question ID is not equal to `SERVING_TYPE_QUESTION_ID`, and then using `R.reject()` from Ramda to create a new array with only the filtered questions. **Ramda Library** The Ramda library provides a more functional programming-oriented approach to filtering data. In this case, the benchmark uses `R.map()` with `R.pipe()` to apply multiple transformations to each element in the array. The first transformation is to filter out questions that have `SERVING_TYPE_QUESTION_ID`, using `R.reject(R.equals(SERVING_TYPE_QUESTION_ID))`. The resulting filtered questions are then transformed into a new array. **Benchmark Results** The benchmark results show two runs, one for native JavaScript pipes and one for the Ramda library. Both approaches produce different results, which is expected given the differences in implementation. **Key Takeaways** * Native JavaScript pipes can be fast, but may not provide the same level of elegance as functional programming libraries like Ramda. * Functional programming libraries like Ramda can provide more concise and expressive code, but may also come with a performance cost due to their additional overhead. * The choice between native JavaScript pipes and a library like Ramda ultimately depends on personal preference, project requirements, and performance considerations. **Advice for Improvement** To improve the benchmark, consider adding more test cases with different input data and filtering operations. This can help identify any biases in the results or edge cases that may not be well-represented. Additionally, exploring other libraries or approaches, such as using `Array.prototype.filter()` instead of `map()`, could provide further insights into the performance characteristics of each approach.
Related benchmarks:
ramda-transducer
ramda-transducer w/mutations
ramda-transducer-push
ramda-transducer-into
ramda-transducer-into-million
Comments
Confirm delete:
Do you really want to delete benchmark?