Msgpack-js vs JSON

JavaScript performance comparison

Revision 3 of this test case created

Info

Comparing the speed of msgpack-js using typed arrays against JSON.parse and JSON.stringify

Preparation code

<script src="https://raw.github.com/creationix/msgpack-js-browser/master/msgpack.js"></script>
<script>
Benchmark.prototype.setup = function() {
    var stringData =
     [
    {"principal_code":"FN","product_code":"1151000","product_type":"Standard","area_type":"Bulk Area Type","location_label":"GS","attribute":null,"quantity":209},
    {"principal_code":"FN","product_code":"1111781","product_type":"Standard","area_type":"Bulk Area Type","location_label":"GS","attribute":null,"quantity":2489},
    {"principal_code":"FN","product_code":"1111545","product_type":"Standard","area_type":"Bulk Area Type","location_label":"GS","attribute":null,"quantity":624},
    {"principal_code":"FN","product_code":"1111503","product_type":"Standard","area_type":"Bulk Area Type","location_label":"GS","attribute":null,"quantity":1896},
    {"principal_code":"FN","product_code":"1111844","product_type":"Standard","area_type":"Bulk Area Type","location_label":"GS","attribute":null,"quantity":26838},
    {"principal_code":"FN","product_code":"1111502","product_type":"Standard","area_type":"Bulk Area Type","location_label":"GS","attribute":null,"quantity":1092},
    {"principal_code":"FN","product_code":"1151003","product_type":"Standard","area_type":"Bulk Area Type","location_label":"GS","attribute":null,"quantity":183},
    {"principal_code":"FN","product_code":"1111528","product_type":"Standard","area_type":"Bulk Area Type","location_label":"GS","attribute":null,"quantity":272},
    {"principal_code":"FN","product_code":"1151002","product_type":"Standard","area_type":"Bulk Area Type","location_label":"GS","attribute":null,"quantity":1296},
    {"principal_code":"FN","product_code":"1151001","product_type":"Standard","area_type":"Bulk Area Type","location_label":"GS","attribute":null,"quantity":597},
    {"principal_code":"FN","product_code":"1111830","product_type":"Standard","area_type":"Bulk Area Type","location_label":"GS","attribute":null,"quantity":4316},
    {"principal_code":"FN","product_code":"1111536","product_type":"Standard","area_type":"Bulk Area Type","location_label":"GS","attribute":null,"quantity":1605},
    {"principal_code":"FN","product_code":"1111826","product_type":"Standard","area_type":"Bulk Area Type","location_label":"GS","attribute":null,"quantity":9432},
    {"principal_code":"FN","product_code":"1111516","product_type":"Standard","area_type":"Bulk Area Type","location_label":"GS","attribute":null,"quantity":6022},
    {"principal_code":"FN","product_code":"1111823","product_type":"Standard","area_type":"Bulk Area Type","location_label":"GS","attribute":null,"quantity":60},
    {"principal_code":"FN","product_code":"1111804","product_type":"Standard","area_type":"Bulk Area Type","location_label":"GS","attribute":null,"quantity":14112},
    {"principal_code":"FN","product_code":"1111824","product_type":"Standard","area_type":"Bulk Area Type","location_label":"GS","attribute":null,"quantity":57794},
    {"principal_code":"FN","product_code":"1111556","product_type":"Standard","area_type":"Bulk Area Type","location_label":"GS","attribute":null,"quantity":85},
    {"principal_code":"FN","product_code":"1111517","product_type":"Standard","area_type":"Bulk Area Type","location_label":"GS","attribute":null,"quantity":2652},
    {"principal_code":"FN","product_code":"1151007","product_type":"Standard","area_type":"Bulk Area Type","location_label":"GS","attribute":null,"quantity":1277},
    {"principal_code":"FN","product_code":"1151005","product_type":"Standard","area_type":"Bulk Area Type","location_label":"GS","attribute":null,"quantity":490},
    {"principal_code":"FN","product_code":"1151006","product_type":"Standard","area_type":"Bulk Area Type","location_label":"GS","attribute":null,"quantity":1819},
    {"principal_code":"FN","product_code":"5000004","product_type":"Point of sales","area_type":"Hold Area Type","location_label":"PL","attribute":null,"quantity":438},
    {"principal_code":"FN","product_code":"1111531","product_type":"Standard","area_type":"Bulk Area Type","location_label":"GS","attribute":null,"quantity":131},
    {"principal_code":"FN","product_code":"1151009","product_type":"Standard","area_type":"Bulk Area Type","location_label":"GS","attribute":null,"quantity":78},
    {"principal_code":"FN","product_code":"1111518","product_type":"Standard","area_type":"Bulk Area Type","location_label":"GS","attribute":null,"quantity":36},
    {"principal_code":"FN","product_code":"1151010","product_type":"Standard","area_type":"Bulk Area Type","location_label":"GS","attribute":null,"quantity":605},
    {"principal_code":"FN","product_code":"1151011","product_type":"Standard","area_type":"Bulk Area Type","location_label":"GS","attribute":null,"quantity":488},
    {"principal_code":"FN","product_code":"1111536","product_type":"Standard","area_type":"Hold Area Type","location_label":"QL","attribute":null,"quantity":240},
    {"principal_code":"FN","product_code":"1111529","product_type":"Standard","area_type":"Bulk Area Type","location_label":"GS","attribute":null,"quantity":12},
    {"principal_code":"FN","product_code":"1111530","product_type":"Standard","area_type":"Bulk Area Type","location_label":"GS","attribute":null,"quantity":4},
    {"principal_code":"FN","product_code":"1111556","product_type":"Standard","area_type":"Hold Area Type","location_label":"QL","attribute":null,"quantity":5},
    {"principal_code":"FN","product_code":"1151010","product_type":"Standard","area_type":"Hold Area Type","location_label":"QL","attribute":null,"quantity":2},
    {"principal_code":"FN","product_code":"1111516","product_type":"Standard","area_type":"Hold Area Type","location_label":"QL","attribute":null,"quantity":2},
    {"principal_code":"FN","product_code":"1111824","product_type":"Standard","area_type":"Hold Area Type","location_label":"QL","attribute":null,"quantity":624},
    {"principal_code":"FN","product_code":"1111844","product_type":"Standard","area_type":"Hold Area Type","location_label":"QL","attribute":null,"quantity":192},
    {"principal_code":"FN","product_code":"1151007","product_type":"Standard","area_type":"Hold Area Type","location_label":"QL","attribute":null,"quantity":48},
    {"principal_code":"FN","product_code":"1151006","product_type":"Standard","area_type":"Hold Area Type","location_label":"QL","attribute":null,"quantity":48},
    {"principal_code":"FN","product_code":"1151005","product_type":"Standard","area_type":"Hold Area Type","location_label":"QL","attribute":null,"quantity":48},
    {"principal_code":"FN","product_code":"1111555","product_type":"Standard","area_type":"Bulk Area Type","location_label":"GS","attribute":null,"quantity":245},
    {"principal_code":"FN","product_code":"1151010","product_type":"Standard","area_type":"Twilight Area Type","location_label":"Tw","attribute":null,"quantity":1},
    {"principal_code":"FN","product_code":"1151007","product_type":"Standard","area_type":"Twilight Area Type","location_label":"Tw","attribute":null,"quantity":19},
    {"principal_code":"FN","product_code":"1111844","product_type":"Standard","area_type":"Twilight Area Type","location_label":"Tw","attribute":null,"quantity":-12},
    {"principal_code":"FN","product_code":"1151000","product_type":"Standard","area_type":"Twilight Area Type","location_label":"Tw","attribute":null,"quantity":9},
    {"principal_code":"FN","product_code":"1151001","product_type":"Standard","area_type":"Twilight Area Type","location_label":"Tw","attribute":null,"quantity":-6},
    {"principal_code":"FN","product_code":"1111536","product_type":"Standard","area_type":"Twilight Area Type","location_label":"Tw","attribute":null,"quantity":38},
    {"principal_code":"FN","product_code":"1111517","product_type":"Standard","area_type":"Twilight Area Type","location_label":"Tw","attribute":null,"quantity":-5},
    {"principal_code":"FN","product_code":"1151002","product_type":"Standard","area_type":"Twilight Area Type","location_label":"Tw","attribute":null,"quantity":-12},
    {"principal_code":"FN","product_code":"1151003","product_type":"Standard","area_type":"Twilight Area Type","location_label":"Tw","attribute":null,"quantity":-16},
    {"principal_code":"FN","product_code":"1111516","product_type":"Standard","area_type":"Twilight Area Type","location_label":"Tw","attribute":null,"quantity":-87},
    {"principal_code":"FN","product_code":"1111503","product_type":"Standard","area_type":"Twilight Area Type","location_label":"Tw","attribute":null,"quantity":-17},
    {"principal_code":"FN","product_code":"1151005","product_type":"Standard","area_type":"Twilight Area Type","location_label":"Tw","attribute":null,"quantity":-19},
    {"principal_code":"FN","product_code":"1111502","product_type":"Standard","area_type":"Twilight Area Type","location_label":"Tw","attribute":null,"quantity":26},
    {"principal_code":"FN","product_code":"1151006","product_type":"Standard","area_type":"Twilight Area Type","location_label":"Tw","attribute":null,"quantity":-25},
    {"principal_code":"FN","product_code":"1111528","product_type":"Standard","area_type":"Twilight Area Type","location_label":"Tw","attribute":null,"quantity":6},
    {"principal_code":"FN","product_code":"1111545","product_type":"Standard","area_type":"Twilight Area Type","location_label":"Tw","attribute":null,"quantity":7},
    {"principal_code":"FN","product_code":"1111555","product_type":"Standard","area_type":"Twilight Area Type","location_label":"Tw","attribute":null,"quantity":23},
    {"principal_code":"FN","product_code":"1111556","product_type":"Standard","area_type":"Twilight Area Type","location_label":"Tw","attribute":null,"quantity":3},
    {"principal_code":"FN","product_code":"1111529","product_type":"Standard","area_type":"Twilight Area Type","location_label":"Tw","attribute":null,"quantity":-1},
    {"principal_code":"FN","product_code":"1111781","product_type":"Standard","area_type":"Twilight Area Type","location_label":"Tw","attribute":null,"quantity":9},
    {"principal_code":"FN","product_code":"1111799","product_type":"Standard","area_type":"Twilight Area Type","location_label":"Tw","attribute":null,"quantity":12},
    {"principal_code":"FN","product_code":"1111804","product_type":"Standard","area_type":"Twilight Area Type","location_label":"Tw","attribute":null,"quantity":-16},
    {"principal_code":"FN","product_code":"1111824","product_type":"Standard","area_type":"Twilight Area Type","location_label":"Tw","attribute":null,"quantity":-112},
    {"principal_code":"FN","product_code":"1111534","product_type":"Standard","area_type":"Bulk Area Type","location_label":"GS","attribute":null,"quantity":41}
    ];
   
    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]
      ]
    ]
   
};
</script>

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 strings
var result = JSON.parse(JSON.stringify(stringData));
pending…
JSON numbers
var result = JSON.parse(JSON.stringify(numberData));
pending…
MsgPack strings
var result = msgpack.decode(msgpack.encode(stringData));
pending…
MsgPack numbers
var result = msgpack.decode(msgpack.encode(numberData));
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