For or while (v6)

Revision 6 of this benchmark created on


Preparation HTML

<script>
  var foo = [];
  for (var i = 0; i < 100000; i++) {
    foo[i] = i;
  }
  var cnt = 0;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
for
for (var i = 0; i <= foo.length; i++) {
  cnt++;
}
ready
while
var i = foo.length;
while (i--) {
  cnt++;
}
ready
reverse for
for (var i = foo.length; i > 0; i--) {
  cnt++;
}
ready
for, cached
var l = foo.length;
for (var i = 0; i <= l; i++) {
  cnt++;
}
ready

Revisions

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