Array length recalculation

JavaScript performance comparison

Test case created

Preparation code

<script>
var i, arr = [];

for (i=0; i < 100000; i++) {
  arr.push(i);
}
</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
Access directly
var i, tmp;

for (i = 0; i < arr.length; i++) {
  tmp = arr[i];
}
pending…
Cache and access
var i, l, tmp;

for (i = 0, l = arr.length; i < l; i++) {
  tmp = arr[i];
}
pending…
Access directly #2
var i, tmp;

for (i = 0; i < arr.length; i++) {
  tmp = arr[i];
}
pending…
Cache and access #2
var i, l, tmp;

for (i = 0, l = arr.length; i < l; i++) {
  tmp = arr[i];
}
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