Map vs. accumulating for

Benchmark created on


Preparation HTML

<script>
  var x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; 
  
  function mult (x) { return 2 * x }; 
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Accumulating for
var res = [];
var len = x.length;
for (var i = 0; i < len; i++) {
  res.push(mult(x[i]))
}
 
ready
Map
x.map(mult)
ready

Revisions

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