Merge Objects vs jQuery .Externd()

JavaScript performance comparison

Revision 2 of this test case created

Info

Testing speed of js merge object properties script vs using jquery's extend method

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
  var settings = { validate: false, limit: 5, name: "foo" };
  var options = { validate: true, name: "bar" };
  function merge_options(obj1,obj2){    var obj3 = {};    for (attrname in obj1) { obj3[attrname] = obj1[attrname]; }    for (attrname in obj2) { obj3[attrname] = obj2[attrname]; }    return obj3;}
</script>

Preparation code output

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
JavaScript
merge_options(settings, options)
pending…
jQuery
jQuery.extend({}, settings, options);
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