Data Selector Performance

JavaScript performance comparison

Revision 14 of this test case created

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<ul id="test">
</ul>
<script>
Benchmark.prototype.setup = function() {
    var i = 500;
    var $ul = $("#test");
    $ul.html('');
    while (i > 0) {
      $ul.append('<li data-component="list-item" data-component2="list-item" class="list-item my-other-class">List Item ' + i.toString() + '</li>');
      i -= 1;
    }
};

Benchmark.prototype.teardown = function() {
    $ul.html('');
};
</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
dataSelector
$ul.find('[data-component="list-item"]')
pending…
classSelector
$ul.find('.list-item')
pending…
two classes
$ul.find('.list-item.my-other-class')
pending…
two dataSelectors
$ul.find('[data-component="list-item"][data-component2="list-item"]')
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:

0 comments

Add a comment