findchildren

JavaScript performance comparison

Test case created by zhuyidong

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<form method="post" action="" id="form-inputs" name="login-form">
  <p class="form-item pr">
    <input name="account" tabindex="1" class="form-input cp" id="username" type="text"
    />
    <label class="pa form-label cp" for="username">
      用户名
    </label>
    <span class="pa form-tip">
    </span>
  </p>
  <p class="form-item pr mt10">
    <input name="password" tabindex="2" class="form-input cp" id="userpass" type="password"
    />
    <label class="pa form-label cp" for="userpass">
      密 码
    </label>
    <span class="pa form-tip">
    </span>
  </p>
  <p class="cb form-misc pt10 pb10">
    <span>
      <input type="checkbox" name="remember-box" id="remember-box" value="0" />
      <label class="remember cp" id="remember-label">
        保持登陆7天
      </label>
    </span>
  </p>
  <p class="pr btn block">
    <button value='Login' class="ti cp btn-submit" id="submitButton" tabIndex="3" type="button">
    </button>
  </p>
</form>
      
<script>
Benchmark.prototype.setup = function() {
  var $parent = $('#form-inputs');
  var _parent = '#form-inputs';
  var _child = '.form-label';

};
</script>

Preparation code output

<form method="post" action="" id="form-inputs" name="login-form"> <p class="form-item pr"> <input name="account" tabindex="1" class="form-input cp" id="username" type="text" /> <label class="pa form-label cp" for="username"> 用户名 </label> <span class="pa form-tip"> </span> </p> <p class="form-item pr mt10"> <input name="password" tabindex="2" class="form-input cp" id="userpass" type="password" /> <label class="pa form-label cp" for="userpass"> 密 码 </label> <span class="pa form-tip"> </span> </p> <p class="cb form-misc pt10 pb10"> <span> <input type="checkbox" name="remember-box" id="remember-box" value="0" /> <label class="remember cp" id="remember-label"> 保持登陆7天 </label> </span> </p> <p class="pr btn block"> <button value='Login' class="ti cp btn-submit" id="submitButton" tabIndex="3" type="button"> </button> </p> </form>

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
$('.child', $parent);
$(_child, $parent);
pending…
$parent.find('.child');
$parent.find(_child);
pending…
$parent.children('.child');
$parent.children(_child);
pending…
$('#parent > .child');
$(_parent +'>'+ _child);
pending…
$('#parent .child');
$(_parent+' '+_child);
pending…
$('.child', $('#parent'));
$(_child, $parent);
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