Sugar.JS performance
JavaScript performance comparison
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.
| Test | Ops/sec | |
|---|---|---|
JQuery.extend |
|
pending… |
Simple clone |
|
pending… |
Simple merge |
|
pending… |
Sugar.js Object.clone |
|
pending… |
Sugar.js Object.merge |
|
pending… |
JQuery deep copy |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments