Object native concatenation versus jQuery.extend()

JavaScript performance comparison

Revision 4 of this test case created

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script>
Benchmark.prototype.setup = function() {
    var mb = {
      prop1: 1,
      prop2: 2,
      method1: function method1() {
        return 1 + 1;
      },
      method2: function method2() {
        return 2 + 2;
      }
    };
    var mb2 = {
      prop3: 3,
      prop4: 4,
      method3: function method3() {
        return 3 + 3;
      },
      method4: function method4() {
        return 4 + 4;
      }
    };
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Native Js
mb.prop3 = mb2.prop3;
mb.prop4 = mb2.prop4;
mb.method3 = mb2.method3;
mb.method4 = mb2.method4;
pending…
jQuery.extend
jQuery.extend(mb, mb2);
pending…
for-in
for (var p in mb2) {
    mb[p] = mb2[p];
}
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