array.length vs. cached (v16)

Revision 16 of this benchmark created on


Setup

var a = [ 0, 1];

Test runner

Ready to run.

Testing in
TestOps/sec
not-cached
(function(a) {
  var sum = 0;
  for (var i = 0; i < a.length; ++i) {
    sum += a[i];
  }
  return sum;
})(a);
ready
cached
(function(a) {
  var sum = 0;
  for (var i = 0, aLen = a.length; i < aLen; ++i) {
    sum += a[i];
  }
  return sum;
})(a);
ready

Revisions

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