<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.25.0/ramda.min.js"></script>
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]
R.includes(47,primes)
primes.includes(79)
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
R.includes | |
array.includes |
Test name | Executions per second |
---|---|
R.includes | 0.0 Ops/sec |
array.includes | 28045032.0 Ops/sec |
Let's break down the provided benchmark and explain what's being tested, compared options, pros/cons of each approach, and other considerations.
Benchmark Overview
The benchmark is designed to compare the performance of two approaches:
R.includes
functionincludes
method (available in modern browsers)Options Compared
The two options being compared are:
Pros and Cons
Pros:
Cons:
Pros:
Cons:
Library Used: Ramda
Ramda is a popular functional programming library for JavaScript. Its primary purpose is to provide a set of reusable functions that can be composed together to solve complex problems. In this benchmark, Ramda's R.includes
function is used to compare its performance with the native implementation.
Special JS Features/ Syntax: None
There are no special JavaScript features or syntax being used in this benchmark. The focus is on comparing two well-known approaches for checking presence in an array.
Other Alternatives
For checking presence in an array, you may also consider:
some
function, which can be optimized for performance.Keep in mind that the choice of approach depends on your specific use case and requirements. This benchmark aims to provide a simple comparison of two widely used methods for checking presence in an array.