Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Lodash intersection vs some+includes
This benchmark compares some algorithms to check if there is an element from an array into another
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Browser:
Chrome 135
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Lodash intersec
12754.5 Ops/sec
some+includes
1042.5 Ops/sec
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))