lodash.uniq vs set

JavaScript performance comparison

Test case created by

Preparation code

<script src="https://lodash.com/vendor/cdn.jsdelivr.net/lodash/4.17.4/lodash.min.js"></script>
      
<script>
Benchmark.prototype.setup = function() {
  var fn1 = function() {
      console.log('hi')
  }
  
  var fn2 = function() {
      console.log('hello');
  }
  
  var arr = [fn1, fn2, fn2, fn1, fn1];
  var result;

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
uniq
result = _.uniq(arr, false, (fn) => {
    return fn.toString();
});
pending…
set
result = [...new Set(arr)]
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

0 Comments