Array Filter perf. (v9)

Revision 9 of this benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="//cdn.jsdelivr.net/lodash/2.4.1/lodash.min.js"></script>
<script src="//knockoutjs.com/downloads/knockout-3.2.0.js"></script>

Setup

var list = [];
    for (var l = 0; l < 100; l++) {
        list[l] = {
            id: l,
            code: l.toString(),
            text: "Item #" + l
        };
    }
    
    var onLoop = function onLoop(item) {
        return item.id > 20 && item.id <= 60;
    };

Test runner

Ready to run.

Testing in
TestOps/sec
KO arrayFilter
ko.utils.arrayFilter(list, onLoop);
ready
_ filter
_.filter(list, onLoop);
ready
jQuery grep
jQuery.grep(list, onLoop);
ready
Native filter
list.filter(onLoop);
ready

Revisions

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