Array.filter vs lodash.filter without bias (v10)

Revision 10 of this benchmark created on


Description

Test performance of native filter method for arrays vs lodash filter method

Preparation HTML

<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.js"></script>

Setup

var a1=[];
    var a2=[];
    
    var b2 = [
        { name: 'john', age: 47 },
        { name: 'jane', age: 22 },
        { name: 'bill', age: 60 }
    ];
    
    for(var i=0;i<1000;i++){
      a1.push(i);
      a2.push(b2[i%3]);
    };

Test runner

Ready to run.

Testing in
TestOps/sec
lodash filter
var r1 = _.filter(a1, function (n) { return n % 2 === 0; });

var r2 = _.filter(a2, function (person) { return person.age > 50; });
ready
Array.filter
var r1 = a1.filter(function (n) { return n % 2 === 0; });

var r2 = a2.filter(function (person) { return person.age > 50; });
ready

Revisions

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