$A.util.fastMap

JavaScript performance comparison

Test case created by zerious

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  window.$A = {
    util: {
      fastMap: function (a, f) {
        for (var l = a.length, b = Array(l), i = 0; i < l; i++) {
          b[i] = f(a[i])
        }
      }
    }
  }
  
  window.a0 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
  window.a1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
  window.a2 = [2, 3, 4, 5, 6, 7, 8, 9, 0, 1];
  window.a3 = [3, 4, 5, 6, 7, 8, 9, 0, 1, 2];
  window.a4 = [4, 5, 6, 7, 8, 9, 0, 1, 2, 3];
  window.a5 = [5, 6, 7, 8, 9, 0, 1, 2, 3, 4];
  window.a6 = [6, 7, 8, 9, 0, 1, 2, 3, 4, 5];
  window.a7 = [7, 8, 9, 0, 1, 2, 3, 4, 5, 6];
  window.a8 = [8, 9, 0, 1, 2, 3, 4, 5, 6, 7];
  window.a9 = [9, 0, 1, 2, 3, 4, 5, 6, 7, 8];

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Array.prototype.map
var b0 = a0.map(function (v) { return v + 1 })
var b1 = a1.map(function (v) { return v + 1 })
var b2 = a2.map(function (v) { return v + 1 })
var b3 = a3.map(function (v) { return v + 1 })
var b4 = a4.map(function (v) { return v + 1 })
var b5 = a5.map(function (v) { return v + 1 })
var b6 = a6.map(function (v) { return v + 1 })
var b7 = a7.map(function (v) { return v + 1 })
var b8 = a8.map(function (v) { return v + 1 })
var b9 = a9.map(function (v) { return v + 1 })
pending…
for loop with push
for (var b0 = [], i0 = 0; i0 < a0.length; i0++) b0.push(a0[i0] + 1)
for (var b1 = [], i1 = 0; i1 < a1.length; i1++) b1.push(a1[i1] + 1)
for (var b2 = [], i2 = 0; i2 < a2.length; i2++) b2.push(a2[i2] + 1)
for (var b3 = [], i3 = 0; i3 < a3.length; i3++) b3.push(a3[i3] + 1)
for (var b4 = [], i4 = 0; i4 < a4.length; i4++) b4.push(a4[i4] + 1)
for (var b5 = [], i5 = 0; i5 < a5.length; i5++) b5.push(a5[i5] + 1)
for (var b6 = [], i6 = 0; i6 < a6.length; i6++) b6.push(a6[i6] + 1)
for (var b7 = [], i7 = 0; i7 < a7.length; i7++) b7.push(a7[i7] + 1)
for (var b8 = [], i8 = 0; i8 < a8.length; i8++) b8.push(a8[i8] + 1)
for (var b9 = [], i9 = 0; i9 < a9.length; i9++) b9.push(a9[i9] + 1)
pending…
$A.util.fastMap
var b0 = $A.util.fastMap(a0, function (v) { return v + 1})
var b1 = $A.util.fastMap(a1, function (v) { return v + 1})
var b2 = $A.util.fastMap(a2, function (v) { return v + 1})
var b3 = $A.util.fastMap(a3, function (v) { return v + 1})
var b4 = $A.util.fastMap(a4, function (v) { return v + 1})
var b5 = $A.util.fastMap(a5, function (v) { return v + 1})
var b6 = $A.util.fastMap(a6, function (v) { return v + 1})
var b7 = $A.util.fastMap(a7, function (v) { return v + 1})
var b8 = $A.util.fastMap(a8, function (v) { return v + 1})
var b9 = $A.util.fastMap(a9, function (v) { return v + 1})
pending…

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

Compare results of other browsers

0 Comments