label selector test

JavaScript performance comparison

Revision 2 of this test case created by David

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<div id="container">
</div>
      
<script>
Benchmark.prototype.setup = function() {
  function run() {
    var results = "",
        btnSetCount = 5000,
        btnCount = 4,
        rbUse = 'radio',
        x = 0,
        y = 0;
  
    while (x < btnSetCount) {
      results += '<div class="btnset">';
      while (y < btnCount) {
        results += '<input type="' + rbUse + '" name="rd-' + x + '" id="rd-' + x + '-' + y + '" /><label for="rd-' + x + '-' + y + '">rd-' + x + '-' + y + '</label>';
        y++;
      }
      y = 0;
      results += '</div>';
      x++;
    }
  }
    run();

};
</script>

Preparation code output

<div id="container"> </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
[for='id']
$('#container').find('[for="rb-250-2"]');
pending…
label[for="id"]
$('#container').find('label[for="rb-250-2"]');
pending…
find(label).filter('for="id"]')
$('#container').find('label').filter('[for="rb-250-2"]');
pending…
.siblings().filter('[for="rb-250-2"]')
$('#rb-250-2').siblings().filter('[for="rb-250-2"]');
pending…
siblings('label')
$( '#rb-250-2' ).siblings( 'label' ).filter('[for="rb-250-2"]');
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