Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
ramdajs contains
(version: 0)
Comparing performance of:
ramdajs contains vs vanilla
Created:
7 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="//cdnjs.cloudflare.com/ajax/libs/ramda/0.25.0/ramda.min.js"></script>
Script Preparation code:
var arr = ['a', 'b', 'c'];
Tests:
ramdajs contains
R.contains('b', arr)
vanilla
arr.includes('b')
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
ramdajs contains
vanilla
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.1:latest
, generated one year ago):
Let's dive into the world of JavaScript benchmarking. **Benchmark Description** The provided JSON represents a benchmark that compares two different approaches to checking if an array contains a specific value: using `R.contains()` from the Ramda library and the native `includes()` method in vanilla JavaScript. **Test Case 1: Ramdajs Contains** This test case uses the `R.contains()` function from the Ramda library. The benchmark definition is simply `"R.contains('b', arr)"`, which means we're checking if the string `'b'` is contained within the array `arr`. The Ramda library is a functional programming library for JavaScript that provides a lot of useful functions, including this `contains()` function. In this case, it's being used to check if an element exists in an array. **Test Case 2: Vanilla** This test case uses the native `includes()` method in vanilla JavaScript. The benchmark definition is simply `"arr.includes('b')"` , which means we're also checking if the string `'b'` is contained within the array `arr`. This is a built-in function that's supported by all modern browsers and Node.js environments. **Benchmark Results** The latest benchmark results show two different execution speeds: * The vanilla `includes()` method runs at approximately 3,595,778 executions per second (eps) on Chrome 66. * The Ramda `contains()` function runs at approximately 11,510,464 eps on the same browser and environment. **Comparison** The main difference between these two approaches is that `R.contains()` from Ramda uses a functional programming style, which can be more expressive and composable than using the native `includes()` method. However, this also means that it might have some performance overhead compared to the built-in function. Pros of using `R.contains()`: * Expressiveness: The functional programming style makes it easier to compose and combine functions. * Reusability: You can use this function in other contexts where you need to check if an element exists in a collection. Cons of using `R.contains()`: * Performance overhead: The benchmark results show that Ramda's `contains()` function is slower than the native `includes()` method. Pros of using the native `includes()` method: * Performance: It's generally faster and more efficient. * Simplicity: You don't need to learn a new library or syntax. Cons of using the native `includes()` method: * Limited expressiveness: The built-in function is more limited in its use cases compared to `R.contains()`. **Alternatives** If you're concerned about performance, you can also consider using other libraries like Lodash or Underscore.js, which provide similar functions for checking if an element exists in a collection. However, keep in mind that these libraries might have their own overhead and might not be as performant as the native `includes()` method. In conclusion, this benchmark shows two different approaches to checking if an array contains a specific value: using Ramda's `contains()` function or the native `includes()` method. While the functional programming style of `R.contains()` has its pros and cons, the vanilla `includes()` method remains a solid choice for performance-critical code.
Related benchmarks:
ramdajs contains
ramdajs contains
Lodash vs Ramda fromPairs
Lodash vs Ramda vs Native fromPairs
Comments
Confirm delete:
Do you really want to delete benchmark?