The cost of using $.extend multiple times

Benchmark created by Jackben on


Description

What kind of overhead does extend have.

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<div id="dropdown" class="headerTopLinks fltrt">
  <form method="post" action="">
    <div>
      <a class="button" href="">Don't log me in</a>
      <input type="text" value="Username" name="username" style="width:210px;" />
      <br/>
      <input type="password" name="password" style="width:168px;margin-right:-3px;" />
      <input type="hidden" name="testcookies" value="1" />
      <input type="submit" value="Login" />
    </div>
  </form>
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
without extend
var settings = { // Set the default values
  'target': $('#dropdown'),
  'firstLoad': true,
  'state': '-100%',
  'animateTime': 500
};
settings['resetField'] = settings['target'].find('input[type~="text"]');
 
ready
With 1 extend
var settings = { // Set the default values
  'target': $('#dropdown'),
  'firstLoad': true,
  'state': '-100%',
  'animateTime': 500
};
$.extend(settings, {
  'resetField': settings['target'].find('input[type~="text"]')
});
ready
With 2 extends
var settings = { // Set the default values
  'target': $('#dropdown'),
  'firstLoad': true,
  'state': '-100%',
  'animateTime': 500
};
$.extend(settings, {
  'resetField': settings['target'].find('input[type~="text"]')
});
$.extend(settings, {
  'resetValue': settings['target'].find('input[type~="text"]')
});
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.