Loops

Benchmark created by Thadeu de Paula 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

Revisions

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