HTML Preparation code:
x
 
1
2
<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 = 490; i >= 0; i--) {
  arr2.push('' + i);
}
Tests:
  • Lodash : small base

     
    const notInArr1 = _.difference(arr2, arr1)
  • Set & Filter: small base

     
    const notInArr1 = arr2.filter(value => !arr1.includes(value));
  • Set & Filter: large base

     
    const notInArr2 = arr1.filter(value => !arr2.includes(value));
  • Lodash: large base

     
    const notInArr2 = _.difference(arr1, arr2)
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Lodash : small base
    Set & Filter: small base
    Set & Filter: large base
    Lodash: large base

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/110.0
Firefox 110 on Mac OS X 10.15
View result in a separate tab
Test name Executions per second
Lodash : small base 2775.3 Ops/sec
Set & Filter: small base 3762.3 Ops/sec
Set & Filter: large base 251.6 Ops/sec
Lodash: large base 8461.9 Ops/sec