Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
lodash intersection test vs Set/Map
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Browser:
Chrome 120
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Lodash
63998.5 Ops/sec
Map/Set
289590.3 Ops/sec
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);
Map/Set
const s = new Set(arr2); arr1.filter(a => s.has(a));