forEach vs forEach cached

JavaScript performance comparison

Test case created by Joshua and last updated

Preparation code

<script>
  Benchmark.prototype.setup = function() {

    var test = [];

    for(var i = 0; i < 2500; i++) {
      test.push(i);
    }

    var iterator = function(t) { return t; };
  };
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
.forEach
test.forEach(function(t) {
  return t;
});
pending…
.forEach Cached
test.forEach(iterator);
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

Add a comment