jQuery 1.5 Unique Traversal

JavaScript performance comparison

Test case created by John Resig

Info

See: http://bugs.jquery.com/ticket/7964

Preparation code

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script>var a = jQuery.noConflict(), aa;</script>
<script src="http://code.jquery.com/jquery-1.5.js"></script>
<script>var b = jQuery.noConflict(), bb;</script>
<div id="tests" style="display:none;"></div>
<script>
 Benchmark.prototype.setup = function() {
  var i, j, ac = 0,
      bc = 0,
      html = "";
 
  for (j = 0; j < 20; j++) {
   html += "<div class='jq144'>";
   for (i = 0; i < 5; i++) {
    html += "<div>abcdefghijklmnopqrstuvwxyz</div><div>0123456789</div>";
   }
   html += "</div>";
  }
 
  for (j = 0; j < 20; j++) {
   html += "<div class='jq150'>";
   for (i = 0; i < 5; i++) {
    html += "<div>abcdefghijklmnopqrstuvwxyz</div><div>0123456789</div>";
   }
   html += "</div>";
  }
  document.getElementById("tests").innerHTML = html;

  aa = a(".jq144");
  bb = b(".jq150");
 };
</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
.children() - jQuery 1.4.4
aa.children();
pending…
.children() - jQuery 1.5
bb.children();
pending…
.next() - jQuery 1.4.4
aa.next();
pending…
.next() - jQuery 1.5
bb.next();
pending…
.prev() - jQuery 1.4.4
aa.prev();
pending…
.prev() - jQuery 1.5
bb.prev();
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:

5 comments

R'Santiago commented :

very useful and interesting information !

Ronak Shah commented :

Hey I got :

19,513 ops/sec for .prev() - jQuery 1.4.4

16,598 ops/sec for .prev() - jQuery 1.5

Testing in Firefox 3.6.13 on Windows 7

How come???

White Rose commented :

The same environment (Windows 7 Utimate, FireFox 3.6.13): .prev() on 1.4.4: 14,595 .prev() on 1.5 : 13,201

Seems that the "Compare results of other browsers" is not correct at all

AlanM commented :

Well it does depend on hardware I would imagine. And also what other apps are running, what plugins do you have installed, etc.. that's why they need a large sample base to estimate performance for "most" users.

Björn commented :

Ronak Shah, White Rose, are you running on the Atom processor?

Add a comment