JSON deep copy vs jQuery Extend

JavaScript performance comparison

Test case created by nik

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
      
<script>
Benchmark.prototype.setup = function() {
  var obj = {
      "glossary": {
          "title": "example glossary",
  		"GlossDiv": {
              "title": "S",
  			"GlossList": {
                  "GlossEntry": {
                      "ID": "SGML",
  					"SortAs": "SGML",
  					"GlossTerm": "Standard Generalized Markup Language",
  					"Acronym": "SGML",
  					"Abbrev": "ISO 8879:1986",
  					"GlossDef": {
                          "para": "A meta-markup language, used to create markup languages such as DocBook.",
  						"GlossSeeAlso": ["GML", "XML"]
                      },
  					"GlossSee": "markup"
                  }
              }
          }
      }
  }

};
</script>

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
JQuery
var clone = jQuery.extend(true, {}, obj);
pending…
JSON Stringify/Parse
var clone = JSON.parse(JSON.stringify(obj)); 
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.

0 Comments