jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
Deep copy/extend objects, jQuery versus other approach(es)
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
/*!
* Copyright Andrée Hansson, 2010
* Use it however you want, attribution would be nice though.
*
* GMail/Twitter: peolanha
* IRC (FreeNode): peol
* Website: http://andreehansson.se/
*/
!
function() {
window.deepCopyObject = function(extendee, extender) {
for (var o in extender) {
extendee[o] = getValue(extender[o]);
}
return extendee;
}
function getValue(obj) {
var
isArray = typeof obj === 'object' && obj.slice,
isObject = typeof obj === 'object',
val, i = 0,
l;
// Array
if (isArray) {
val = Array.prototype.slice.apply(obj);
l = val.length;
do {
val[i] = getValue(val[i]);
}
while (++i < l);
}
// Object
else if (isObject) {
val = deepCopyObject({}, obj);
}
// Others
else {
val = obj;
}
return val;
}
}();
var a = {
a: '1',
b: {
a: '1',
b: [{
a: '1'
},
{
b: '1'
},
{
c: '1'
},
{
d: '1'
}]
}
};
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
jQuery |
| ready |
Other |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.