jQuery Multiple Selector Performance Problems (v2)

Revision 2 of this benchmark created on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>
  var jq142 = jQuery.noConflict();
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script>
  var jq143 = jQuery.noConflict();
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script>
  var jq151 = jQuery.noConflict();
</script>
<script src="http://code.jquery.com/jquery-git.js"></script>
<script>
  var jqgit = jQuery.noConflict();
</script>
<div class="test" id="test">
  <script>
    var html = "";
    for ( var j = 0; j < 20; j++ ) {
      html += '<div id="bigdiv' + j + '">';

      for ( var i = 0; i < 1000; i++ ) {
        html += '<div class="find"></div>';
      }

      html += '</div>';
    }
    document.write( html );
  </script>
  <input name='testinput' type='hidden' />
  <select name='testselect'><option>1</option><option>2</option></select>
</div>
<script>
  var $jq142 = jq142("body");
  var $jq143 = jq143("body");
  var $jq151 = jq151("body");
  var $jqgit = jqgit("body");
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
input,select - 1.4.2
$jq142.find("input,select");
ready
input,select - 1.4.3
$jq143.find("input,select");
ready
input,select - 1.5.1
$jq151.find("input,select");
ready
input,select - GIT
$jqgit.find("input,select");
ready
input only - GIT
$jqgit.find("input");
ready
select only - GIT
$jqgit.find("select");
ready
input then select - GIT
$jqgit.find("input");
$jqgit.find("select");
ready
input then add() select - GIT
$jqgit.find("input").add("select");
ready
input,select - 1.4.3
$jq143.find("input");
$jq143.find("select");
ready

Revisions

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