Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
lodash difference vs ES6 Set (large set)
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/123.0.0.0 Safari/537.36
Browser:
Chrome 123
Operating system:
Linux
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
_difference
1505.1 Ops/sec
Set/Filter
1762.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:
var arr1 = []; for(let i = 0; i < 10000; i++) { arr1.push('' + i); } var arr2 = []; for(let i = 499; i >= 0; i--) { arr2.push('' + i); }
Tests:
_difference
const finalArray1 = _.difference(arr1, arr2) const finalArray2 = _.difference(arr2, arr1)
Set/Filter
const outList2 = new Set([...arr2]); const outList1 = new Set([...arr1]); const finalArray1 = arr1.filter(value => !outList2.has(value)); const finalArray2 = arr2.filter(value => !outList1.has(value));