es2016 vs _.clone vs Object.assign

JavaScript performance comparison

Test case created by Hawken Rives

Preparation code

<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.10.1/lodash.min.js"></script>
<script>
var babel = function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
</script>
      
<script>
Benchmark.prototype.setup = function() {
  var obj = {a: 1}
  var objWithArray = {a: 1, b: [1, 2, 3]}

};
</script>

Preparation code output

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
{…}
var x = babel({}, obj)
pending…
_.clone
var x = _.clone(obj)
pending…
{…} with array
var x = babel({}, objWithArray)
pending…
_.clone with array
var x = _.clone(objWithArray)
pending…
Object.assign
var x = Object.assign({}, obj)
pending…
Object.assign array
var x = Object.assign({}, objWithArray)
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.

0 Comments