Object deep copy small test
JavaScript performance comparison
Info
jQuery vs JSON
Preparation code
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
function cloneObject(obj) {
var clone = {};
for(var i in obj) {
if(typeof(obj[i])=="object")
clone[i] = cloneObject(obj[i]);
else
clone[i] = obj[i];
}
return clone;
}
</script>
<script>
Benchmark.prototype.setup = function() {
var doc = {
"A7yzo8WcBQqTKjBeDPnA" : {
"connectTime" : 1358468820297,
"sharingAudio" : true,
"sharingVideo" : true,
"sharingData" : false,
"stats" : [{
"remote" : null,
"local" : null
}, {
"remote" : null,
"local" : null
}, {
"remote" : null,
"local" : null
}, {
"remote" : null,
"local" : null
}
]
},
"B7yzo8WcBQqTKjBeDPnB" : {
"connectTime" : 1358468820297,
"sharingAudio" : true,
"sharingVideo" : true,
"sharingData" : false,
"stats" : [{
"remote" : null,
"local" : null
}, {
"remote" : null,
"local" : null
}, {
"remote" : null,
"local" : null
}, {
"remote" : null,
"local" : null
}
]
},
"C7yzo8WcBQqTKjBeDPnC" : {
"connectTime" : 1358468820297,
"sharingAudio" : true,
"sharingVideo" : true,
"sharingData" : false,
"stats" : [{
"remote" : null,
"local" : null
}, {
"remote" : null,
"local" : null
}, {
"remote" : null,
"local" : null
}, {
"remote" : null,
"local" : null
}
]
}
}
};
</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… |
JSON parser |
|
pending… |
Eval |
|
pending… |
Clone |
|
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:
- Revision 1: published
- Revision 2: published
- Revision 3: published
0 comments