Loops (v3)

Revision 3 of this benchmark created on


Description

Test using many ways of iteration, with and without plugins

Preparation HTML

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
 
<script>
  var x = 0,
      xArr = [];
  for (var x = 0; x < 2000; x++) xArr.push('1');
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
while decrements
var a = x.length,
    b = 0;
while (a--) b++;
ready
for 3 steps
for (var a = x.length, b = 0; b < a; b++) {}
ready
jQuery Each
var b = 0;
jQuery(x).each(function() {
 b++;
});
ready
for 3 steps (length chk)
var b = 0;
for (var a = 0; a < x.length; a++) {
 b++;
}
ready
for in
var b = 0;
for (i in x) {
 b++;
}
ready

Revisions

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