Script Preparation code:
x
 
var obj = {};
var objCount = 100;
for (let i = 0; i < objCount; i++) {
    obj[i] = [1, 2, 3];
}
function deepClone(objIn) {
    let copy;
    if (objIn === null || typeof objIn !== 'object') {
        return obj;
    }
    if (objIn instanceof Array) {
        copy = [];
        for (let i = 0, len = objIn.length; i < len; i++) {
            copy[i] = deepClone(objIn[i]);
        }
        return copy;
    }
    if (objIn instanceof Object) {
        copy = {};
        for (const attr in objIn) {
            if (objIn.hasOwnProperty(attr)) {
                copy[attr] = deepClone(objIn[attr]);
            }
        }
        return copy;
    }
}
function deepMerge(target, ...sources) {
 if (!sources.length) return target
 const source = sources.shift()
 if (isObject(target) && isObject(source)) {
  for (const key in source) {
   if (isObject(source[key])) {
    if (!target[key]) Object.assign(target, {[key]: {}})
    deepMerge(target[key], source[key])
   } else {
    Object.assign(target, {[key]: source[key]})
   }
  }
 }
 return deepMerge(target, ...sources)
}
function isObject(obj) {
 return obj && typeof obj === "object" && !Array.isArray(obj) 
}
Tests:
  • DeepClone

     
    var clone = deepClone(obj);
  • JSON.stringify

     
    var clone = JSON.parse(JSON.stringify(obj));
  • deepMerge

     
    var clone = deepMerge({}, obj)
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    DeepClone
    JSON.stringify
    deepMerge

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one month ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Chrome 133 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
DeepClone 215411.1 Ops/sec
JSON.stringify 112040.7 Ops/sec
deepMerge 35537.2 Ops/sec