Object.create vs {$,_}.extend (v2)

Revision 2 of this benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>

Setup

var instance1 = {
      value1: 1,
      value2: 2,
      value3: 3
    };

Teardown


    if (result.value1 != 1) throw Error(1);
    if (result.value2 != 2) throw Error(2);
    if (result.value3 != 3) throw Error(3);
    if (result.value4 != 4) throw Error(4);
  

Test runner

Ready to run.

Testing in
TestOps/sec
Object.create
var result = Object.create(instance1)

result.value4 = 4;
ready
$.extend
var result = $.extend(instance1, {
  value4: 4
});
ready
_.extend
var result = _.extend(instance1, {
  value4: 4
});
ready

Revisions

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