selecting limited elements

JavaScript performance comparison

Revision 3 of this test case created by

Preparation code

<ul>
<li>link 1</li>
<li>link 2</li>
<li>link 3</li>
<li>link 4</li>
<li class='active'>link 1</li>
<li>link 6</li>
<li>link 7</li>
<li>link 8</li>
<li>link 9</li>
</ul>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

      
<script>
Benchmark.prototype.setup = function() {
  var active = $("li.active");

};
</script>

Preparation code output

<ul> <li>link 1</li> <li>link 2</li> <li>link 3</li> <li>link 4</li> <li class='active'>link 1</li> <li>link 6</li> <li>link 7</li> <li>link 8</li> <li>link 9</li> </ul>

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
prevUntil - nextUntil
var el = active.add(active.nextUntil(':lt(2)'))
        .add(active.prevUntil(':lt(2)'));
pending…

Revisions

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

0 Comments