Table rows - native loop vs jquery each iterator

JavaScript performance comparison

Revision 3 of this test case created

Info

table rows native loop vs jquery each iterator

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
  var $table = $('<table border="1"><tbody></tbody></table>'),
      rows = $table.children().append(Array(301).join('<tr><td>1</td><td>2</td></tr>'))[0].rows,
      row, i = 0,
      len, rl;
</script>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
while
i = 0;
while (row = rows[i++]) {
 row; // html table row element
}
pending…
jquery each
jQuery.each(rows, function() {
 this; // html table row element
})
pending…
for
for (i = 0, len = rows.length; i < len; i++) {
 row = rows[i]; // html table row element
};
pending…
for 2
for (; row = rows[i++];) {
 row; // html table row element
}
pending…
for 3
for (len = rows.length; i < len; i++) {
 row = rows[i]; // html table row element
};
pending…
for 4
for (rl = rows.length; i < rl; i++) {
 row = rows[i]; // html table row element
}
pending…
for 5
for (; row = rows[i]; i++) {
 row; // html table row element
}
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment