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
 
const max2 = 10000000; // 10,000,000 (10 Million)
const arr2 = Array.from({ length: 10000000 }, (_, i) => Math.random() >= 0.5 ? ({ id: i }) : ({ id: Math.floor(Math.random() * 10) + 1 }))
Tests:
  • Lodash (_.uniqBy)

     
    _.uniqBy(arr2, (el) => el.id)
  • Vanilla code

     
    const idsAlreadySeen = new Set();
    const uniqArr = arr2.filter(data => {
      if (idsAlreadySeen.has(data.id)) {
        return false;
      }
      
      idsAlreadySeen.add(data.id);
      return true;
    });
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Lodash (_.uniqBy)
    Vanilla code

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 11 days ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Chrome 134 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
Lodash (_.uniqBy) 2.4 Ops/sec
Vanilla code 0.8 Ops/sec