Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Lodash difference vs Set & Filter vs 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/131.0.0.0 Safari/537.36 Edg/131.0.0.0
Browser:
Chrome 131
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Lodash
147.5 Ops/sec
Set & Filter
222.3 Ops/sec
map
153.0 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:
var arr1 = []; for(let i = 0; i < 100000; i++) { arr1.push({"index": i}); } var arr2 = []; for(let i = 49000; i >= 0; i--) { arr2.push(arr1[i*2]); }
Tests:
Lodash
const notInArr = _.difference(arr2, arr1)
Set & Filter
const arr2Set = new Set(arr2); const notInArr2 = arr1.filter(value => !arr2Set.has(value));
map
const arr2Map = new Map(arr2.map((e2) => ([e2.index, e2]))); const notInArr2 = arr1.filter(value => !arr2Map.has(value));