custom underscore extend vs jquery extend (v4)

Revision 4 of this benchmark created by tex on


Description

Testing a custom version of underscore extend without side effects.

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script src="http://documentcloud.github.com/underscore/underscore-min.js">
</script>
<script>
  var slice = Array.prototype.slice,
      customExtend = function(obj) {
      copy = _.clone(obj);
      _.each(slice.call(arguments, 1), function(source) {
        for (var prop in source) {
          copy[prop] = source[prop];
        }
      });
      return copy;
      },
      options = {
      name: "Dave",
      age: 26,
      family: {
        father: true,
        mother: true
      }
      },
      addlOptions = {
      occupation: "lumberjack",
      education: "phd",
      children: {
        daughters: ['stephanie', 'amanda'],
        sons: ['william']
      }
      };
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
custom underscore extend
customExtend(options, addlOptions, {
  age: 27
});
ready
underscore extend
_.extend(options, addlOptions, {
  age: 27
});
ready
jquery deep extend
$.extend(true, options, addlOptions, {
  age: 27
});
ready
jquery extend
$.extend(options, addlOptions, {
  age: 27
});
ready

Revisions

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