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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 OPR/106.0.0.0
Browser:
Opera 106
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Lodash
82784.2 Ops/sec
Map/Set
315686.8 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));