map vs native for loop (v14)

Revision 14 of this benchmark created on


Description

test the performance of the jquery map versus a native for loop map

Setup

testArray = new Array(100);
    
    for(var i = 0; i < 100; i++) {
      testArray[i] = i;
    }
    
    function map(arr, fun) {
    var ret = [];
    for(var i = 0; i < 100; i++) {
      ret.push(fun(testArray[i]));
    }
    return ret;
    }
    function double (x) {
      return x*2;
    }

Test runner

Ready to run.

Testing in
TestOps/sec
jquery map
var result = testArray.map(double);
ready
for loop map
var result = map(testArray, double);
ready

Revisions

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