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 arr = [];
var map = new Map();
for (let i = 1; i <= 10000; i++) {
    //let r = makeid(6);
    let r = Math.random().toString(36).substring(8);
    arr.push({
        r
    });
    map.set(r, {
        r
    });
}
Tests:
  • map

     
    let smain = [];
    for (let s of map.values() ) {
      smain.push({r: s.r, r2: s.r + s.r})
    }
  • lodash

     
    let main = _.uniqBy(arr, 'r').map(ar => ({r: ar.r, r2: ar.r + ar.r}))
  • arr map

     
    let newarr = Array.from(map);
    let newarr2 = [];
    newarr.forEach((s) => {
      newarr2.push({r: s.r, r2: s.r + s.r})
    })
  • arr map2

     
    let newarr = Array.from(map, s => ({r: s.r, r2: s.r + s.r}))
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    map
    lodash
    arr map
    arr map2

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 4 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.123 Safari/537.36
Chrome 85 on Mac OS X 10.15.6
View result in a separate tab
Test name Executions per second
map 3237.5 Ops/sec
lodash 571.7 Ops/sec
arr map 1036.6 Ops/sec
arr map2 2230.7 Ops/sec