prime-vs-underscore-vs-lodash

JavaScript performance comparison

Revision 2 of this test case created by arian

Preparation code

<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.1/lodash.min.js"></script>
<script src="https://gist.github.com/arian/e0decb013500b6cbc44d/raw/427083351384f0479313a1aa51b5b3c4ef219b99/shell.mixin.js"></script>

<script>
var lodash = _.noConflict();
</script>
      
<script>
Benchmark.prototype.setup = function() {
  var x = 'x';
  var array = Array(31).join(x).split();
  
  var shell = window.shell;
  
  shell.array.implement({
    ret1: function(){
      return this;
    }
  });
  
  shell.array.mixin({
    ret2: function(self){
      return self;
    }
  });
  
  var primeChaining = shell.array(array);
  
  var _ = window._;
  
  _.mixin({
    ret: function(self){
      return self;
    }
  });
  
  var _chaining = _(array).chain();
  
  var lodash = window.lodash;
  
  lodash.mixin({
    ret: function(self){
      return self;
    }
  });
  
  var lodashChaining = _(array);

};
</script>

Preparation code output

<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.1/lodash.min.js"></script> <script src="https://gist.github.com/arian/e0decb013500b6cbc44d/raw/427083351384f0479313a1aa51b5b3c4ef219b99/shell.mixin.js"></script> <script> var lodash = _.noConflict(); </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
Prime wrapped
var result = shell.array.ret1(array);
pending…
Lo-Dash w/ Chaining
var result = lodashChaining.ret();
pending…
Prime generic
var result = shell.array.ret2(array);
pending…
Prime wrapped w/ Chaining
var result = primeChaining.ret1()
pending…
Underscore
var result = _.ret(array);
pending…
Underscore w/ Chaining
var result = _chaining.ret();
pending…
Lo-Dash
var result = lodash.ret(array);
pending…
Prime generic \w chaining
var result = primeChaining.ret2()
pending…

Compare results of other browsers

Revisions

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

0 Comments