Array Filter perf. (v5)

Revision 5 of this benchmark created by MS on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="https://underscorejs.org/underscore-min.js"></script>
<script src="https://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.