HTML Preparation code:
AخA
 
1
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.4/lodash.min.js"></script>
2
<script src="https://cdn.jsdelivr.net/npm/underscore@1.13.1/underscore-min.js"></script>
Script Preparation code:
x
 
var underscore = _.noConflict();
var objectArrays = [
  ['bedroom', 'kitchen', 'bathroom', 'living room', 'indoors', 'outdoors', 'city', 'urban', 'villa', 'hotel'],
  ['bed', 'kitchen island', 'bath', 'room', 'city'],
  ['bed', 'bathroom', 'bath', 'room', 'city']
];
Tests:
  • manual lodash

     
    let shared = [];
    objectArrays.forEach((array, i) => {
      if (i === 0) {
        shared.push(...array);
      }
      else {
        _.intersection(shared, array);
      }
    });
  • manual underscore

     
    let shared = [];
    objectArrays.forEach((array, i) => {
      if (i === 0) {
        shared.push(...array);
      }
      else {
        underscore.intersection(shared, array);
      }
    });
  • Lodash

     
    const arrayLodash = _.intersection(...objectArrays);
  • Underscore

     
    const arrayUnderscore = underscore.intersection(...objectArrays);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    manual lodash
    manual underscore
    Lodash
    Underscore

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36
Chrome 100 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
manual lodash 447775.0 Ops/sec
manual underscore 624814.6 Ops/sec
Lodash 866699.6 Ops/sec
Underscore 1333295.5 Ops/sec