Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
array includes ramda lodash
(version: 0)
Comparing performance of:
_.includes vs array.includes vs ramda includes
Created:
6 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.25.0/ramda.min.js"></script>
Script Preparation code:
var primes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,97]
Tests:
_.includes
_.includes(primes, 47);
array.includes
primes.includes(79);
ramda includes
R.includes
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
_.includes
array.includes
ramda includes
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 benchmark and explain what's being tested. **What is being tested?** The provided JSON represents a JavaScript microbenchmark that tests the performance of three different approaches to check if an element exists in an array: 1. `_.includes` (Ramda library): This function checks if an element is present in an array using Ramda's `includes` function. 2. `array.includes`: This is a built-in JavaScript method that checks if an element is present in an array. 3. `R.includes` (Ramda library): This is another version of the includes function provided by Ramda, but with slightly different behavior. **Options compared** The three options are being compared to measure their performance difference: * **Pro's of each approach:** + `_.includes` and `array.includes`: These built-in JavaScript methods are likely to be fast and efficient since they're implemented in native code. + `R.includes`: This Ramda function might have some overhead due to its use of a custom implementation, but it may also offer benefits like better type inference or more concise code. * **Con's of each approach:** + `_.includes` and `array.includes`: These methods require the array to be in scope, which can add extra memory allocations or garbage collection pauses depending on the context. + `R.includes`: This Ramda function might not be as efficient as the built-in methods, but it could also lead to more predictable performance since it's implemented in a specific way. **Library and its purpose** * `lodash.js` (Lodash library): Lodash is a popular utility library for JavaScript that provides a wide range of functions for tasks like string manipulation, array processing, and more. The `_.includes` function is part of the Lodash library and is used here as a benchmarking tool. * `ramda.min.js` (Ramda library): Ramda is another functional programming library for JavaScript that offers a more concise and expressive way to write code. The `R.includes` function is an example of how Ramda can implement common array operations in its own way. **Special JS feature or syntax** There doesn't seem to be any special JavaScript features or syntax being used here. All the code looks like standard ES6+ JavaScript. **Other alternatives** If you're interested in exploring alternative approaches, here are a few examples: * `Array.prototype.some()` or `Array.prototype.every()`: These methods can be used as an alternative to `array.includes` since they also check for existence. * Custom implementation using a simple loop: You could write a custom function that uses a simple loop to iterate through the array and check if the target element is present. This approach would likely be slower than the built-in methods or Ramda's includes functions, but it might give you insight into how such a function would work. Keep in mind that this benchmark focuses on performance, so using an alternative implementation like `Array.prototype.some()` or a simple loop might skew the results due to extra overhead.
Related benchmarks:
array includes
array includes 2
ramda includes vs native
Ramda vs vanilla JS
Comments
Confirm delete:
Do you really want to delete benchmark?