Deep Copy vs JSON Stringify / JSON Parse

JavaScript performance comparison

Revision 86 of this test case created by Jonathan Perry

Preparation code

Benchmark.prototype.setup = function() {
  function deepCopy(o) {
       *  Assume that `reduce` is slow, for now
      if (Array.isArray(o)) return o.reduce((a, c) => a.concat(deepCopy(c)), [])
      if ((o || false) instanceof Object) {
          const r = {}
          for (k in o) {
              const c = o[k];
              r[k] = deepCopy(c);
          return r;
  var uc = {bir:{iki:{uc:3}}}


Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
JSON Stringify / JSON Parse
var bes = JSON.parse(JSON.stringify(uc))
Deep Copy
var bes = deepCopy(uc)

Compare results of other browsers


You can edit these tests or add even more tests to this page by appending /edit to the URL.