js eq vs find

JavaScript performance comparison

Test case created

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<table id="gpd_table" cellpadding="0" cellspacing="0" border="1" class="display dataTable"
aria-describedby="gpd_table_info">
  <thead>
    <tr role="row">
      <th class="sorting_desc" tabindex="0" rowspan="1" colspan="1" style="width: 80.18466019630432px;"
     aria-label="last_name: activate to sort column ascending">
        last_name
      </th>
      <th class="sorting" tabindex="0" rowspan="1" colspan="1" style="width: 82.18466019630432px;"
     aria-label="first_name: activate to sort column ascending">
        first_name
      </th>
      <th class="sorting_disabled" tabindex="0" rowspan="1" colspan="1" style="width: 40.18466019630432px;"
     aria-label="PA_1">
        PA_1
      </th>
      <th class="sorting_disabled" tabindex="0" rowspan="1" colspan="1" style="width: 40.18466019630432px;"
     aria-label="PA_2">
        PA_2
      </th>
      <th class="sorting_disabled" tabindex="0" rowspan="1" colspan="1" style="width: 40.18466019630432px;"
     aria-label="PS_1">
        PS_1
      </th>
      <th class="sorting_disabled" tabindex="0" rowspan="1" colspan="1" style="width: 40.18466019630432px;"
     aria-label="PS_2">
        PS_2
      </th>
      <th class="sorting_disabled" tabindex="0" rowspan="1" colspan="1" style="width: 40.18466019630432px;"
     aria-label="TB_1">
        TB_1
      </th>
      <th class="sorting_disabled" tabindex="0" rowspan="1" colspan="1" style="width: 40.18466019630432px;"
     aria-label="TB_2">
        TB_2
      </th>
    </tr>
  </thead>
  <tbody role="alert" aria-live="polite" aria-relevant="all">
    <tr id="hky8816" class="odd">
      <td class=" sorting_1">
        Yu
      </td>
      <td class="">
        Helen
      </td>
      <td class="">
        15
      </td>
      <td class="">
        18
      </td>
      <td class="">
        12
      </td>
      <td class="">
        9
      </td>
      <td class="">
        18
      </td>
      <td class="">
        18
      </td>
    </tr>
    <tr id="pxy5151" class="even">
      <td class=" sorting_1">
        Yeung
      </td>
      <td class="">
        Peter
      </td>
      <td class="">
        18
      </td>
      <td class="">
        16
      </td>
      <td class="">
        9
      </td>
      <td class="">
        9
      </td>
      <td class="">
        12
      </td>
      <td class="">
        17
      </td>
    </tr>
    <tr id="ray9006" class="odd">
      <td class=" sorting_1">
        Yemerou
      </td>
      <td class="">
        Requique
      </td>
      <td class="">
        15
      </td>
      <td class="">
        14
      </td>
      <td class="">
        15
      </td>
      <td class="">
        17
      </td>
      <td class="">
        9
      </td>
      <td class="">
        17
      </td>
    </tr>
    <tr id="mpw4065" class="even">
      <td class=" sorting_1">
        Woodard
      </td>
      <td class="">
        Matthew
      </td>
      <td class="">
        18
      </td>
      <td class="">
        15
      </td>
      <td class="">
        11
      </td>
      <td class="">
        17
      </td>
      <td class="">
        16
      </td>
      <td class="">
        15
      </td>
    </tr>
    <tr id="amw1051" class="odd">
      <td class=" sorting_1">
        Wilson-Daeschlein
      </td>
      <td class="">
        Amber
      </td>
      <td class="">
        16
      </td>
      <td class="">
        20
      </td>
      <td class="">
        20
      </td>
      <td class="">
        17
      </td>
      <td class="">
        20
      </td>
      <td class="">
        20
      </td>
    </tr>
    <tr id="wad8993" class="even">
      <td class=" sorting_1">
        Wilson
      </td>
      <td class="">
        Darko
      </td>
      <td class="">
        17
      </td>
      <td class="">
        11
      </td>
      <td class="">
        18
      </td>
      <td class="">
        13
      </td>
      <td class="">
        18
      </td>
      <td class="">
        19
      </td>
    </tr>
    <tr id="cjw7558" class="odd">
      <td class=" sorting_1">
        Williams
      </td>
      <td class="">
        Caitlin
      </td>
      <td class="">
        9
      </td>
      <td class="">
        9
      </td>
      <td class="">
        10
      </td>
      <td class="">
        10
      </td>
      <td class="">
        8
      </td>
      <td class="">
        15
      </td>
    </tr>
    <tr id="lsw9216" class="even">
      <td class=" sorting_1">
        Williams
      </td>
      <td class="">
        Lorael
      </td>
      <td class="">
        17
      </td>
      <td class="">
        17
      </td>
      <td class="">
        19
      </td>
      <td class="">
        15
      </td>
      <td class="">
        6
      </td>
      <td class="">
        14
      </td>
    </tr>
    <tr id="jcw8139" class="odd">
      <td class=" sorting_1">
        Wilcox
      </td>
      <td class="">
        Jascha
      </td>
      <td class="">
        11
      </td>
      <td class="">
        12
      </td>
      <td class="">
        9
      </td>
      <td class="">
        5
      </td>
      <td class="">
        15
      </td>
      <td class="">
        13
      </td>
    </tr>
    <tr id="mww7408" class="even">
      <td class=" sorting_1">
        Whiteford
      </td>
      <td class="">
        Matthew
      </td>
      <td class="">
        9
      </td>
      <td class="">
        16
      </td>
      <td class="">
        19
      </td>
      <td class="">
        11
      </td>
      <td class="">
        15
      </td>
      <td class="">
        15
      </td>
    </tr>
  </tbody>
</table>

Preparation code output

last_name first_name PA_1 PA_2 PS_1 PS_2 TB_1 TB_2
Yu Helen 15 18 12 9 18 18
Yeung Peter 18 16 9 9 12 17
Yemerou Requique 15 14 15 17 9 17
Woodard Matthew 18 15 11 17 16 15
Wilson-Daeschlein Amber 16 20 20 17 20 20
Wilson Darko 17 11 18 13 18 19
Williams Caitlin 9 9 10 10 8 15
Williams Lorael 17 17 19 15 6 14
Wilcox Jascha 11 12 9 5 15 13
Whiteford Matthew 9 16 19 11 15 15

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
eq
$('#gpd_table thead th:eq(2)').text();
pending…
find
$('#gpd_table').find('th:eq(2)').text();
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