Data Selector Performance

JavaScript performance comparison

Revision 35 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 type="text/javascript">
var ul = $("#test");
var i = 500;
while (i > 0) {
  ul.append("<li data-component=\"i" + i + "\" class=\"i" + i + " my-other-class\">List Item " + i.toString() + "</li>");
  i -= 1;
}
</script>
<script>
Benchmark.prototype.setup = function() {
    var i = 500;
   
};
</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 (variable)
while (i > 0) {
  $("[data-component=\"i" + i + "\"]", ul)
  i -= 1;
}
pending…
classSelector (variable)
while (i > 0) {
  $(".i" + i, ul)
  i -= 1;
}
pending…
two classes (variable + fixed)
while (i > 0) {
  $(".my-other-class.i" + i, ul)
  i -= 1;
}
pending…
classSelector (fixed)
while (i > 0) {
  $(".my-other-class", ul)
  i -= 1;
}
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