jquery eq() as selector vs chained method vs css nthchild

JavaScript performance comparison

Revision 3 of this test case created by Test00001

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<table class="dataTable">
 <thead>
  <tr>
   <th>
    ALT
   </th>
   <th>
    3000
   </th>
   <th>
    6000
   </th>
   <th>
    9000
   </th>
   <th>
    12000
   </th>
   <th>
    18000
   </th>
   <th>
    24000
   </th>
   <th>
    30000
   </th>
   <th>
    34000
   </th>
   <th>
    39000
   </th>
   <th>
    45000
   </th>
   <th>
    53000
   </th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>
    ACK
   </td>
   <td>
    2609
   </td>
   <td>
    2906+09
   </td>
   <td>
    2806+04
   </td>
   <td>
    2809-02
   </td>
   <td>
    9900-16
   </td>
   <td>
    3605-29
   </td>
   <td>
    061245
   </td>
   <td>
    081853
   </td>
   <td>
    051560 
   </td>
   <td>
    &nbsp;
   </td>
   <td>
    &nbsp;
   </td>
  </tr>
  <tr>
   <td>
    ALB
   </td>
   <td>
    2007
   </td>
   <td>
    2805+08
   </td>
   <td>
    9900+03
   </td>
   <td>
    9900-02
   </td>
   <td>
    9900-15
   </td>
   <td>
    0206-28
   </td>
   <td>
    060845
   </td>
   <td>
    091653
   </td>
   <td>
    061057 
   </td>
   <td>
    341959
   </td>
   <td>
    361963 
   </td>
  </tr>
  <tr>
   <td>
    BDL
   </td>
   <td>
    2407
   </td>
   <td>
    9900+09
   </td>
   <td>
    2105+04
   </td>
   <td>
    2005-02
   </td>
   <td>
    9900-16
   </td>
   <td>
    0206-29
   </td>
   <td>
    041045
   </td>
   <td>
    081553
   </td>
   <td>
    051258 
   </td>
   <td>
    &nbsp;
   </td>
   <td>
    &nbsp;
   </td>
  </tr>
  <tr>
   <td>
    BGR
   </td>
   <td>
    3019
   </td>
   <td>
    3116+10
   </td>
   <td>
    3113+04
   </td>
   <td>
    3212-02
   </td>
   <td>
    3411-15
   </td>
   <td>
    3611-27
   </td>
   <td>
    031944
   </td>
   <td>
    022154
   </td>
   <td>
    361763 
   </td>
   <td>
    &nbsp;
   </td>
   <td>
    &nbsp;
   </td>
  </tr>
  <tr>
   <td>
    BML
   </td>
   <td>
    2909
   </td>
   <td>
    2911+10
   </td>
   <td>
    3006+04
   </td>
   <td>
    9900-02
   </td>
   <td>
    3605-15
   </td>
   <td>
    0107-28
   </td>
   <td>
    101843
   </td>
   <td>
    091853
   </td>
   <td>
    070762 
   </td>
   <td>
    &nbsp;
   </td>
   <td>
    &nbsp;
   </td>
  </tr>
  <tr>
   <td>
    BOS
   </td>
   <td>
    2711
   </td>
   <td>
    3107+09
   </td>
   <td>
    2807+03
   </td>
   <td>
    2705-02
   </td>
   <td>
    9900-16
   </td>
   <td>
    0406-28
   </td>
   <td>
    071345
   </td>
   <td>
    082052
   </td>
   <td>
    071361 
   </td>
   <td>
    012459
   </td>
   <td>
    362364 
   </td>
  </tr>
  <tr>
   <td>
    JFK
   </td>
   <td>
    1610
   </td>
   <td>
    1508+07
   </td>
   <td>
    1411+03
   </td>
   <td>
    1408-01
   </td>
   <td>
    1206-16
   </td>
   <td>
    0910-28
   </td>
   <td>
    070845
   </td>
   <td>
    070854
   </td>
   <td>
    021355 
   </td>
   <td>
    361958
   </td>
   <td>
    011365 
   </td>
  </tr>
  <tr>
   <td>
    PLB
   </td>
   <td>
    9900
   </td>
   <td>
    2710+09
   </td>
   <td>
    2407+03
   </td>
   <td>
    1206-01
   </td>
   <td>
    9900-15
   </td>
   <td>
    3605-28
   </td>
   <td>
    070844
   </td>
   <td>
    092152
   </td>
   <td>
    090860 
   </td>
   <td>
    331959
   </td>
   <td>
    342562 
   </td>
  </tr>
  <tr>
   <td>
    PWM
   </td>
   <td>
    2811
   </td>
   <td>
    3208+09
   </td>
   <td>
    2906+03
   </td>
   <td>
    9900-02
   </td>
   <td>
    3407-16
   </td>
   <td>
    0108-28
   </td>
   <td>
    091643
   </td>
   <td>
    082253
   </td>
   <td>
    070962 
   </td>
   <td>
    &nbsp;
   </td>
   <td>
    &nbsp;
   </td>
  </tr>
  <tr>
   <td>
    YSC
   </td>
   <td>
    &nbsp;
   </td>
   <td>
    &nbsp;
   </td>
   <td>
    &nbsp;
   </td>
   <td>
    &nbsp;
   </td>
   <td>
    &nbsp;
   </td>
   <td>
    0105-28
   </td>
   <td>
    121343
   </td>
   <td>
    071653
   </td>
   <td>
    020562
   </td>
   <td>
    332359
   </td>
   <td>
    342762 
   </td>
  </tr>
 </tbody>
</table>

      
<script>
Benchmark.prototype.setup = function() {
  var $base = $("tbody"),
  testIndex = 6;

};
</script>

Preparation code output

<table class="dataTable"> <thead> <tr> <th> ALT </th> <th> 3000 </th> <th> 6000 </th> <th> 9000 </th> <th> 12000 </th> <th> 18000 </th> <th> 24000 </th> <th> 30000 </th> <th> 34000 </th> <th> 39000 </th> <th> 45000 </th> <th> 53000 </th> </tr> </thead> <tbody> <tr> <td> ACK </td> <td> 2609 </td> <td> 2906+09 </td> <td> 2806+04 </td> <td> 2809-02 </td> <td> 9900-16 </td> <td> 3605-29 </td> <td> 061245 </td> <td> 081853 </td> <td> 051560 </td> <td> &nbsp; </td> <td> &nbsp; </td> </tr> <tr> <td> ALB </td> <td> 2007 </td> <td> 2805+08 </td> <td> 9900+03 </td> <td> 9900-02 </td> <td> 9900-15 </td> <td> 0206-28 </td> <td> 060845 </td> <td> 091653 </td> <td> 061057 </td> <td> 341959 </td> <td> 361963 </td> </tr> <tr> <td> BDL </td> <td> 2407 </td> <td> 9900+09 </td> <td> 2105+04 </td> <td> 2005-02 </td> <td> 9900-16 </td> <td> 0206-29 </td> <td> 041045 </td> <td> 081553 </td> <td> 051258 </td> <td> &nbsp; </td> <td> &nbsp; </td> </tr> <tr> <td> BGR </td> <td> 3019 </td> <td> 3116+10 </td> <td> 3113+04 </td> <td> 3212-02 </td> <td> 3411-15 </td> <td> 3611-27 </td> <td> 031944 </td> <td> 022154 </td> <td> 361763 </td> <td> &nbsp; </td> <td> &nbsp; </td> </tr> <tr> <td> BML </td> <td> 2909 </td> <td> 2911+10 </td> <td> 3006+04 </td> <td> 9900-02 </td> <td> 3605-15 </td> <td> 0107-28 </td> <td> 101843 </td> <td> 091853 </td> <td> 070762 </td> <td> &nbsp; </td> <td> &nbsp; </td> </tr> <tr> <td> BOS </td> <td> 2711 </td> <td> 3107+09 </td> <td> 2807+03 </td> <td> 2705-02 </td> <td> 9900-16 </td> <td> 0406-28 </td> <td> 071345 </td> <td> 082052 </td> <td> 071361 </td> <td> 012459 </td> <td> 362364 </td> </tr> <tr> <td> JFK </td> <td> 1610 </td> <td> 1508+07 </td> <td> 1411+03 </td> <td> 1408-01 </td> <td> 1206-16 </td> <td> 0910-28 </td> <td> 070845 </td> <td> 070854 </td> <td> 021355 </td> <td> 361958 </td> <td> 011365 </td> </tr> <tr> <td> PLB </td> <td> 9900 </td> <td> 2710+09 </td> <td> 2407+03 </td> <td> 1206-01 </td> <td> 9900-15 </td> <td> 3605-28 </td> <td> 070844 </td> <td> 092152 </td> <td> 090860 </td> <td> 331959 </td> <td> 342562 </td> </tr> <tr> <td> PWM </td> <td> 2811 </td> <td> 3208+09 </td> <td> 2906+03 </td> <td> 9900-02 </td> <td> 3407-16 </td> <td> 0108-28 </td> <td> 091643 </td> <td> 082253 </td> <td> 070962 </td> <td> &nbsp; </td> <td> &nbsp; </td> </tr> <tr> <td> YSC </td> <td> &nbsp; </td> <td> &nbsp; </td> <td> &nbsp; </td> <td> &nbsp; </td> <td> &nbsp; </td> <td> 0105-28 </td> <td> 121343 </td> <td> 071653 </td> <td> 020562 </td> <td> 332359 </td> <td> 342762 </td> </tr> </tbody> </table>

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
in selector
$base.children(":eq(" + testIndex + ")");
pending…
chained method
$base.children().eq(testIndex);
pending…
rewrap
$($base.children()[testIndex]);
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

ALT 3000 6000 9000 12000 18000 24000 30000 34000 39000 45000 53000
ACK 2609 2906+09 2806+04 2809-02 9900-16 3605-29 061245 081853 051560    
ALB 2007 2805+08 9900+03 9900-02 9900-15 0206-28 060845 091653 061057 341959 361963
BDL 2407 9900+09 2105+04 2005-02 9900-16 0206-29 041045 081553 051258    
BGR 3019 3116+10 3113+04 3212-02 3411-15 3611-27 031944 022154 361763    
BML 2909 2911+10 3006+04 9900-02 3605-15 0107-28 101843 091853 070762    
BOS 2711 3107+09 2807+03 2705-02 9900-16 0406-28 071345 082052 071361 012459 362364
JFK 1610 1508+07 1411+03 1408-01 1206-16 0910-28 070845 070854 021355 361958 011365
PLB 9900 2710+09 2407+03 1206-01 9900-15 3605-28 070844 092152 090860 331959 342562
PWM 2811 3208+09 2906+03 9900-02 3407-16 0108-28 091643 082253 070962    
YSC           0105-28 121343 071653 020562 332359 342762