Msgpack-js vs JSON (v23)

Revision 23 of this benchmark created on


Description

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

Preparation HTML

<script src="https://rawgithub.com/creationix/msgpack-js-browser/master/msgpack.js"></script>

Setup

var stringData = [
      {
        "_id": "53d1b607f314cb3002e2e19e",
        "index": 0,
        "guid": "683ba22b-6d56-4cc6-91bb-04c9de20135f",
        "isActive": false,
        "balance": "$3,313.42",
        "picture": "http://placehold.it/32x32",
        "age": 20,
        "eyeColor": "brown",
        "name": "Chrystal Harris",
        "gender": "female",
        "company": "CENTREGY",
        "email": "chrystalharris@centregy.com",
        "phone": "+1 (907) 452-2558",
        "address": "577 Middleton Street, Catharine, North Dakota, 7667",
        "about": "Proident anim sint enim adipisicing. Laborum sunt excepteur quis minim quis consectetur minim mollit adipisicing cillum esse reprehenderit aute. Nulla ea nisi do duis fugiat fugiat sunt sint.\r\n",
        "registered": "2014-04-02T06:05:05 +04:00",
        "latitude": 47.526035,
        "longitude": -139.224276,
        "tags": [
          "magna",
          "minim",
          "eu",
          "mollit",
          "et",
          "ullamco",
          "exercitation"
        ],
        "friends": [
          {
            "id": 0,
            "name": "James Morrow"
          },
          {
            "id": 1,
            "name": "Olga Tran"
          },
          {
            "id": 2,
            "name": "Leanne Bender"
          }
        ],
        "greeting": "Hello, Chrystal Harris! You have 2 unread messages.",
        "favoriteFruit": "apple"
      },
      {
        "_id": "53d1b60769fdc924c67b9a58",
        "index": 1,
        "guid": "6493c72f-d899-4f81-910b-ec4ccf0a98cd",
        "isActive": false,
        "balance": "$1,869.73",
        "picture": "http://placehold.it/32x32",
        "age": 30,
        "eyeColor": "brown",
        "name": "Carissa Guerra",
        "gender": "female",
        "company": "ACCUPRINT",
        "email": "carissaguerra@accuprint.com",
        "phone": "+1 (802) 447-3128",
        "address": "248 Revere Place, Macdona, Vermont, 7177",
        "about": "Voluptate id ad sunt aliqua excepteur cupidatat non excepteur. Deserunt quis quis consequat aute laborum commodo occaecat occaecat minim adipisicing dolor non nostrud. Non nisi irure Lorem esse reprehenderit deserunt anim est Lorem sit incididunt ipsum labore. Fugiat magna elit occaecat magna est. Officia ea id fugiat labore ex sit eu occaecat id. Adipisicing enim fugiat exercitation culpa mollit tempor quis consequat labore adipisicing eiusmod enim veniam eu. Esse do deserunt fugiat non exercitation adipisicing voluptate deserunt id adipisicing dolore officia.\r\n",
        "registered": "2014-04-27T00:23:53 +04:00",
        "latitude": 13.991163,
        "longitude": 175.160083,
        "tags": [
          "do",
          "consequat",
          "sunt",
          "amet",
          "aliqua",
          "excepteur",
          "ex"
        ],
        "friends": [
          {
            "id": 0,
            "name": "Perez Larson"
          },
          {
            "id": 1,
            "name": "Augusta Hensley"
          },
          {
            "id": 2,
            "name": "Reeves Trujillo"
          }
        ],
        "greeting": "Hello, Carissa Guerra! You have 7 unread messages.",
        "favoriteFruit": "strawberry"
      },
      {
        "_id": "53d1b607a2f8b658ebe4403c",
        "index": 2,
        "guid": "6435e60a-9a34-41fa-ab8f-0c29762f5d6f",
        "isActive": true,
        "balance": "$2,385.38",
        "picture": "http://placehold.it/32x32",
        "age": 30,
        "eyeColor": "green",
        "name": "Dickerson Hebert",
        "gender": "male",
        "company": "COMCUBINE",
        "email": "dickersonhebert@comcubine.com",
        "phone": "+1 (800) 480-3037",
        "address": "341 Veranda Place, Shindler, Alaska, 702",
        "about": "Quis reprehenderit cupidatat dolore dolor aliqua officia amet. Ut exercitation reprehenderit eiusmod labore est elit Lorem velit ex exercitation laborum Lorem in. Anim eiusmod ea esse ipsum irure. Ut magna est non eu esse officia cupidatat ipsum ad. Incididunt aute nisi ad ea pariatur ipsum fugiat nostrud ut velit Lorem elit consectetur.\r\n",
        "registered": "2014-04-16T07:17:02 +04:00",
        "latitude": 68.439464,
        "longitude": -44.634377,
        "tags": [
          "adipisicing",
          "mollit",
          "in",
          "amet",
          "minim",
          "minim",
          "sunt"
        ],
        "friends": [
          {
            "id": 0,
            "name": "Avery Pruitt"
          },
          {
            "id": 1,
            "name": "Minerva Glover"
          },
          {
            "id": 2,
            "name": "Cash Wright"
          }
        ],
        "greeting": "Hello, Dickerson Hebert! You have 10 unread messages.",
        "favoriteFruit": "strawberry"
      },
      {
        "_id": "53d1b6077bb7319b2df0e648",
        "index": 3,
        "guid": "f1238166-7c2d-4a83-aa67-8c7599704377",
        "isActive": true,
        "balance": "$1,126.21",
        "picture": "http://placehold.it/32x32",
        "age": 38,
        "eyeColor": "brown",
        "name": "Chambers Vaughan",
        "gender": "male",
        "company": "MEDICROIX",
        "email": "chambersvaughan@medicroix.com",
        "phone": "+1 (989) 586-2270",
        "address": "467 Canton Court, Worton, Ohio, 6277",
        "about": "Officia consequat nisi cupidatat proident nostrud excepteur sit. Officia eu excepteur consequat Lorem sunt dolore occaecat eu non nulla. Deserunt occaecat ex sunt enim labore ut quis est tempor culpa ut sint sunt occaecat. Pariatur ut sunt nulla in quis in sit irure amet occaecat deserunt nostrud aliquip. Dolore aute magna minim tempor occaecat veniam proident reprehenderit ut ullamco ad.\r\n",
        "registered": "2014-05-31T14:19:50 +04:00",
        "latitude": 38.696438,
        "longitude": 99.123178,
        "tags": [
          "proident",
          "Lorem",
          "tempor",
          "non",
          "sunt",
          "nostrud",
          "incididunt"
        ],
        "friends": [
          {
            "id": 0,
            "name": "Rebecca Bond"
          },
          {
            "id": 1,
            "name": "Sherrie Kim"
          },
          {
            "id": 2,
            "name": "Angeline Potts"
          }
        ],
        "greeting": "Hello, Chambers Vaughan! You have 10 unread messages.",
        "favoriteFruit": "banana"
      },
      {
        "_id": "53d1b6076556f25f46f9699a",
        "index": 4,
        "guid": "3b256d88-af54-4baa-ad3c-b17b76ea0cf1",
        "isActive": true,
        "balance": "$2,470.27",
        "picture": "http://placehold.it/32x32",
        "age": 28,
        "eyeColor": "blue",
        "name": "Houston Chapman",
        "gender": "male",
        "company": "GENESYNK",
        "email": "houstonchapman@genesynk.com",
        "phone": "+1 (885) 454-2615",
        "address": "291 Highland Avenue, Caroleen, Kentucky, 1482",
        "about": "Nulla ad minim aute pariatur sit. Ea ex elit voluptate est quis consequat cupidatat labore eu eu. Cillum elit enim eiusmod aliqua esse.\r\n",
        "registered": "2014-05-15T02:27:26 +04:00",
        "latitude": 43.722809,
        "longitude": -179.804803,
        "tags": [
          "velit",
          "deserunt",
          "consequat",
          "labore",
          "mollit",
          "proident",
          "pariatur"
        ],
        "friends": [
          {
            "id": 0,
            "name": "Rena Moss"
          },
          {
            "id": 1,
            "name": "Jodi Blankenship"
          },
          {
            "id": 2,
            "name": "Christian Marshall"
          }
        ],
        "greeting": "Hello, Houston Chapman! You have 3 unread messages.",
        "favoriteFruit": "apple"
      },
      {
        "_id": "53d1b607969fbb84b763f961",
        "index": 5,
        "guid": "bfbc7aaa-3be8-462a-90a7-1039cc92a0dd",
        "isActive": false,
        "balance": "$1,790.03",
        "picture": "http://placehold.it/32x32",
        "age": 21,
        "eyeColor": "blue",
        "name": "Socorro Wooten",
        "gender": "female",
        "company": "VIXO",
        "email": "socorrowooten@vixo.com",
        "phone": "+1 (937) 593-3670",
        "address": "143 Heyward Street, Gibsonia, New Jersey, 6468",
        "about": "Id eiusmod nulla deserunt enim consectetur eiusmod. Pariatur duis pariatur aliquip do eu ut veniam velit ea magna dolor. Sint do labore incididunt amet exercitation id adipisicing pariatur. Irure esse velit deserunt labore incididunt consectetur labore eiusmod nulla anim. Commodo adipisicing ea consequat esse eiusmod esse fugiat consequat do nulla. Esse cillum dolor occaecat adipisicing nostrud laboris eiusmod sit in laborum dolore.\r\n",
        "registered": "2014-04-02T12:52:52 +04:00",
        "latitude": 84.705745,
        "longitude": 18.765077,
        "tags": [
          "do",
          "reprehenderit",
          "est",
          "adipisicing",
          "voluptate",
          "consectetur",
          "aliqua"
        ],
        "friends": [
          {
            "id": 0,
            "name": "Craft Harvey"
          },
          {
            "id": 1,
            "name": "Talley Sears"
          },
          {
            "id": 2,
            "name": "Lyons Mueller"
          }
        ],
        "greeting": "Hello, Socorro Wooten! You have 5 unread messages.",
        "favoriteFruit": "strawberry"
      }
    ]
    
    
    ;
    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]
      ]
    ]

Test runner

Ready to run.

Testing in
TestOps/sec
JSON strings
var result = JSON.parse(JSON.stringify(stringData));
ready
JSON numbers
var result = JSON.parse(JSON.stringify(numberData));
ready
MsgPack strings
var result = msgpack.decode(msgpack.encode(stringData));
ready
MsgPack numbers
var result = msgpack.decode(msgpack.encode(numberData));
ready

Revisions

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