underscore / lodash - without

JavaScript performance comparison

Revision 13 of this test case created

Preparation code

<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js">
</script>
<script>
  var underscore = _.noConflict();
</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js">
</script>
<script>
  var lodash = _.noConflict();
</script>
<script>
Benchmark.prototype.setup = function() {
    var lodash = window.lodash,
        underscore = window.underscore;
   
    var r,
        array = [];
   
    for (var i = 0; i < 1000000; i++) {
      array[i] = i;
    }
   
    underscore.mixin({
          remove: function(array, item) {
            array = array.slice();
            var index = array.indexOf(item);
            if (index != -1) {
                array.splice(index, 1);
            }
            return array;
          }
        });
   
    underscore.mixin({
          remove_mutate: function(array, item) {
            var index = array.indexOf(item);
            if (index != -1) {
                array.splice(index, 1);
            }
            return array;
          }
        });
};
</script>

Preparation code output

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
without underscore
r = [];
underscore.without(array, 10);
pending…
without lodash
r = [];
lodash.without(array, 10);
pending…
slice(indexOf) native
r = [];
array.splice(array.indexOf(10), 1);
pending…
remove lodash
r = [];
lodash.remove(array, 10);
pending…
underscore remove mixin
r = [];
underscore.remove(array, 10);
pending…
underscore remove_mutate mixin
r = [];
underscore.remove_mutate(array, 10);
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. Here’s a list of current revisions for this page:

0 comments

Add a comment