Sugar.JS performance

JavaScript performance comparison

Test case created

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://shovkoplyas.pro/sugar-1.2.1.min.js"></script>
<script>
function clone(obj) {
   var target = {};
   for (var i in obj) {
    if (obj.hasOwnProperty(i)) {
     target[i] = obj[i];
    }
   }
   return target;
  }

function merge(destination, source) {
   for (var i in source) {
    if (source.hasOwnProperty(i)) {
     destination[i] = source[i];
    }
   }
   return destination;
  }
</script>
<script>
Benchmark.prototype.setup = function() {
    o = {
      a: 1, b: 2, c: 3, d: 4,
      e: { a: 1, b: 2, c: 3, d: 4 },
      f: { a: 1, b: 2, c: 3, d: 4 },
      g:
        [
          {a: 1, b: 2, c: 3, d: 4},
          {a: 1, b: 2, c: 3, d: 4}
        ]
    }
   
    u = {
      foo: 'bar',
      baz: 'trololo'
    }
};
</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
JQuery.extend
var foo = jQuery.extend({}, o);
pending…
Simple clone
var foo = clone(o)
pending…
Simple merge
var foo = merge(u, o)
pending…
Sugar.js Object.clone
var foo = Object.clone(o)
pending…
Sugar.js Object.merge
var foo = Object.merge(u, o)
pending…
JQuery deep copy
var foo = jQuery.extend(true, u, o);
pending…

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

Compare results of other browsers

0 comments

Add a comment