HTML Preparation code:
AخA
 
1
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.4/lodash.min.js"></script>
Script Preparation code:
x
 
var max1 = 100000; // 100,000 (100 Thousand)
var max2 = 10000000; // 10,000,000 (10 Million)
var max3 = 100000000; // 100,000,000 (100 Million)
var arr1 = [];
//for (var i = 0; i <= max1; i++) { arr1.push(i); }
var arr2 = [];
for (var i = 0; i <= max2; i++) { arr2.push({name: i, value: Math.floor(Math.random() * 100) }); }
var arr3 = [];
//for (var i = 0; i <= max3; i++) { arr3.push(i); }
Tests:
  • Native

     
    const removeDuplicates = (objects, propertyName) => {
      const uniqueValues = new Set();
      return objects.filter((o) => {
        const isNewValue = !uniqueValues.has(o[propertyName]);
        uniqueValues.add(o[propertyName]);
        return isNewValue;
      });
    };
    removeDuplicates(arr2, 'value')
  • Lodash.js filter

     
    const removeDuplicates = (objects, propertyName) => {
      _.uniqBy(objects, propertyName)
    };
    removeDuplicates(arr2, 'value')
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Native
    Lodash.js filter

    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_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36
Chrome 109 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
Native 2.9 Ops/sec
Lodash.js filter 3.6 Ops/sec