traversing menu awful selector

JavaScript performance comparison

Test case created by Rick Waldron

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>


<!-- #menu>ul>li>ul>li>a -->
<div id="menu">
  <ul>
    <li><a href="#a">alpha</a></li>
    <li><a href="#b">beta</a></li>
    <li>
      <ul>
        <li><a href="#g">gamma</a></li>
        <li><a href="#d">delta</a></li>
        <li><hr></li>  
        <li><a href="#e">epsilon</a></li>
        <li><a href="#z">zeta</a></li>
          
      </ul>
    </li>
    <li>
      <ul>
        <li><a href="#h">eta</a></li>
        <li><hr></li>  
        <li><a href="#i">iota</a></li>
        <li><a href="#k">kappa</a></li>
          
      </ul>
    </li>
  </ul>
</div>
    

Preparation code output

<!-- #menu>ul>li>ul>li>a --> <div id="menu"> <ul> <li><a href="#a">alpha</a></li> <li><a href="#b">beta</a></li> <li> <ul> <li><a href="#g">gamma</a></li> <li><a href="#d">delta</a></li> <li><hr></li> <li><a href="#e">epsilon</a></li> <li><a href="#z">zeta</a></li> </ul> </li> <li> <ul> <li><a href="#h">eta</a></li> <li><hr></li> <li><a href="#i">iota</a></li> <li><a href="#k">kappa</a></li> </ul> </li> </ul> </div>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
current
$("#menu").children("ul").find("ul").children().children("a").parent()
pending…
suggested
$("#menu").children("ul").find("ul li a").parent()
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.

0 Comments