Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash intersection vs some+includes
(version: 0)
This benchmark compares some algorithms to check if there is an element from an array into another
Comparing performance of:
Lodash intersec vs some+includes
Created:
7 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
function makeid(len = 5) { var text = ""; var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; for (let i = 0; i < len; i++) text += possible.charAt(Math.floor(Math.random() * possible.length)); return text; } var arr1 = [] var arr2 = [] for (let i = 0; i < 1000; i++) { arr1.push(makeid()) arr2.push(makeid()) } // To ensure that both arrays has at least 1 element in common arr1[arr1.length - 1] = arr2[0]
Tests:
Lodash intersec
_.intersection(arr1, arr2).length > 0
some+includes
arr1.some(el => arr2.includes(el))
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Lodash intersec
some+includes
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36
Browser/OS:
Chrome 136 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Lodash intersec
14789.8 Ops/sec
some+includes
1041.5 Ops/sec
Related benchmarks:
native intersect vs lodash intersection
Lodash difference vs filtering via set membership with high overlap
Array Intersection vs. Set Intersection vs. Lodash - big
intersectionWith vs find in find vs set small
intersectionWith vs find in find vs set big
Comments
Confirm delete:
Do you really want to delete benchmark?