Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
check 2 arrays
(version: 0)
Comparing performance of:
lodash vs filter includes vs Map/Set
Created:
3 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.15/lodash.min.js"></script>
Script Preparation code:
var arr1 = []; for (var i = 0; i <= 100; i++) { arr1.push({ id: i, text: 'blabla-' + i }); } var arr2 = []; for (var i = 0; i <= 150; i+=2) { arr2.push({ id: i, text: 'blabla-' + i }); }
Tests:
lodash
_.intersectionWith(arr1, arr2, (a,b) => a.id == b.id);
filter includes
arr1.filter(a => arr2.includes(a) );
Map/Set
const s = new Set(arr2); arr1.filter(a => s.has(a));
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
lodash
filter includes
Map/Set
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!
Related benchmarks:
_.isEmpty vs !array || !array.length
Test Array Speed
lodash difference vs ES6 Set
Spread Operator vs Lodash [2]
Array From vs lodash clone
Comments
Confirm delete:
Do you really want to delete benchmark?