Array filter performance (v5)

Revision 5 of this benchmark created on


Setup

var alpha = [1, 2, 3, 4, 5, 6];
    
    var testElement = function(i) {
        return i > 3;
        }

Test runner

Ready to run.

Testing in
TestOps/sec
Filter
var result = alpha.filter(testElement(i));
ready
Loop
function filter(a) {
  var match = []

  for (var i = 0; i < a.length; i++) {
    if (testElement(i)) match.push(a[i])
  }

  return match
}

var result = filter(alpha);
ready

Revisions

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