Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:94.0) Gecko/20100101 Firefox/94.0
Firefox 94
Mac OS X 10.15
Desktop
3 years ago
Test name Executions per second
set 6824063.0 Ops/sec
uniq 7982080.5 Ops/sec
HTML Preparation code:
x
 
1
2
<script src='https://cdn.jsdelivr.net/npm/lodash@4.17.10/lodash.min.js'></script>
Script Preparation code:
 
var arr = [5,1,3,7,9,2,11];
var mySet = new Set(arr);
Tests:
  • set

     
    mySet.add(12);
    mySet.add(12);
    mySet.add(5);
    mySet.add(17);
    mySet.add(1);
    mySet.add(11);
    return arr;
  • uniq

     
    arr = _.uniq(arr.push(12));
    arr = _.uniq(arr.push(12));
    arr = _.uniq(arr.push(5));
    arr = _.uniq(arr.push(17));
    arr = _.uniq(arr.push(1));
    arr = _.uniq(arr.push(12));
    return arr;