Script Preparation code:
Tests:
  • var child = JSON.parse(JSON.stringify(parent));

  • child[i] = parent[i].slice()/// var child = []; for (var i = 0; i < parent.length; i += 1) { child[i] = parent[i].slice(); }

  • child[i][j] = parent[i][j]/// var child = []; for (var i = 0; i < parent.length; i += 1) { child[i] = []; for (var j = 0; j < parent[i].length; j += 1) { child[i][j] = parent[i][j]; } }

  • var child = JSON.parse(JSON.stringify(sparent));

  • var child = sparent.slice();

  • child[i] = sparent[i]/// var child = []; for (var i = 0; i < parent.length; i += 1) { child[i] = sparent[i]; }

Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results
  • Test case name Result
    var child = JSON.parse(JSON.stringify(parent));
    child[i] = parent[i].slice()/// var child = []; for (var i = 0; i < parent.length; i += 1) { child[i] = parent[i].slice(); }
    child[i][j] = parent[i][j]/// var child = []; for (var i = 0; i < parent.length; i += 1) { child[i] = []; for (var j = 0; j < parent[i].length; j += 1) { child[i][j] = parent[i][j]; } }
    var child = JSON.parse(JSON.stringify(sparent));
    var child = sparent.slice();
    child[i] = sparent[i]/// var child = []; for (var i = 0; i < parent.length; i += 1) { child[i] = sparent[i]; }

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 5 years ago)
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36
Chrome 70 on Windows 7
View result in a separate tab
Test name Executions per second
var child = JSON.parse(JSON.stringify(parent)); 81848.1 Ops/sec
child[i] = parent[i].slice()/// var child = []; for (var i = 0; i < parent.length; i += 1) { child[i] = parent[i].slice(); } 259871.2 Ops/sec
child[i][j] = parent[i][j]/// var child = []; for (var i = 0; i < parent.length; i += 1) { child[i] = []; for (var j = 0; j < parent[i].length; j += 1) { child[i][j] = parent[i][j]; } } 36270.2 Ops/sec
var child = JSON.parse(JSON.stringify(sparent)); 198205.4 Ops/sec
var child = sparent.slice(); 5601047.0 Ops/sec
child[i] = sparent[i]/// var child = []; for (var i = 0; i < parent.length; i += 1) { child[i] = sparent[i]; } 279773.5 Ops/sec


;