Does #id el find all els first? (v9)

Revision 9 of this benchmark created by Lars on


Description

Making the HTML tree more representative of cases where performance would matter, i.e. where there are more elements of the selected type, especially outside of the #id element.

Added test case #5, 'el el', where we remove one variable from the equation as compared to '#id el': the likelihood of a Sizzle optimization that applies when the select begins with #id; and we remove another variable from the equation as compared to unrestricted 'el': the cost of "decorating" a collection of DOM nodes (which I take to mean, packaging them as jQuery objects).

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<span><div id="id"><span/></div></span>
<span/><span/><span/><span/>
<span>
  <span/><span/><span/><span/>
  <span/><span/><span/><span/>
  <span>
    <span/><span/><span/><span/>
    <span/><span/><span/><span/>
  </span>
</span>

Test runner

Ready to run.

Testing in
TestOps/sec
#id el
$('#id span')
ready
el unrestricted
$('span')
ready
find
$("#id").find("span")
ready
context
$("span", "#id")
ready
el el
$("div span")
ready

Revisions

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