json2 vs jquery json

JavaScript performance comparison

Revision 2 of this test case created

Info

native json.stringify() vs json2.stringify() vs json3.stringify() vs jquery.json.toJSON()

Preparation code

<script>
  this.JSONNATIVE = this.JSON;
  this.JSON = false;
</script>

<script src="http://www.x-non.com/json/json2.min.js"></script>
<script>
  this.JSON2 = this.JSON;
  this.JSON = false;
</script>

<script src="http://www.x-non.com/json/json3.min.js"></script>
<script>
  this.JSON3 = this.JSON;
  this.JSON = false;
</script>

<script src="http://www.x-non.com/json/jquery-1.9.1.min.js"></script>
<script
src="http://www.x-non.com/json/jquery.json-2.4.min.js"></script>
<script>
Benchmark.prototype.setup = function() {
    var value = {
        kitcambridge: "Kit",
        contributors: {
                jdalton: "John-David",
                mathias:"Mathias"
        },
        list: [1,2,3],
        number: 5,
        date: "2012-04-25T14:08:36.879Z",
        bln: true,
        nil: null
    };
};
</script>

Preparation code output

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
json native
var a = JSONNATIVE.stringify(value);
 
pending…
json 2
var a = JSON2.stringify(value);

 
pending…
json3
var a = JSON3.stringify(value);
pending…
jquery.json
var a = $.toJSON(value);
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. Here’s a list of current revisions for this page:

0 comments

Add a comment