Msgpack vs json performance

JavaScript performance comparison

Revision 18 of this test case created by

Preparation code

<script src="https://rawgit.com/msgpack/msgpack-javascript/master/msgpack.js"></script>
<script>
  Benchmark.prototype.setup = function() {
    var stringData = {"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"}}}}};
    var numberData = [
      [1, 2, 3, 4, -1, true, null],
      [3, 6, 5, 4,  1, false, 7],
      [3, 2, 8, 1,  0, true, 0],
      [10, 11, 12, 13,  14, false, true],
      [15, 16, 17, 18, 19, true, null],
      [20, 21, 22, 23,  24, false, 7],
      [25, 26, 27, 28,  29, true, 0],
      100, 200, 300,
      [
        [1, 0, 0, 0, 0],
        [0, 1, 0, 0, 0],
        [0, 0, 1, 0, 0],
        [0, 0, 0, 1, 0],
        [0, 0, 0, 0, 1]
      ]
    ];
    var jsonEncodedStrings = JSON.stringify(stringData),
        jsonEncodedNumbers = JSON.stringify(numberData),
        msgpackEncodedStrings = msgpack.pack(stringData),
        msgpackEncodedNumbers = msgpack.pack(numberData);
  };
</script>
    

Preparation code output

<script> Benchmark.prototype.setup = function() { var stringData = {"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"}}}}}; var numberData = [ [1, 2, 3, 4, -1, true, null], [3, 6, 5, 4, 1, false, 7], [3, 2, 8, 1, 0, true, 0], [10, 11, 12, 13, 14, false, true], [15, 16, 17, 18, 19, true, null], [20, 21, 22, 23, 24, false, 7], [25, 26, 27, 28, 29, true, 0], 100, 200, 300, [ [1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1] ] ]; var jsonEncodedStrings = JSON.stringify(stringData), jsonEncodedNumbers = JSON.stringify(numberData), msgpackEncodedStrings = msgpack.pack(stringData), msgpackEncodedNumbers = msgpack.pack(numberData); }; </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
Msgpack Numbers Encode
var result = msgpack.pack(numberData);
pending…
JSON Strings Encode
var result = JSON.stringify(stringData);
pending…
JSON Numbers Encode
var result = JSON.stringify(numberData);
pending…
Msgpack Strings Encode
var result = msgpack.pack(stringData);
pending…

Revisions

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

0 Comments