HTML Preparation code:
AخA
 
1
<script src="https://unpkg.com/msgpackr@1.7.2/dist/index.min.js"></script>
Script Preparation code:
 
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 packer = new msgpackr.Packr({
    // shouldShareStructure(keys){ return true },
    // maxSharedStructures: 1024,
    // randomAccessStructure: true,
    structures: []
});
var jsonEncodedStrings = JSON.stringify(stringData),
    jsonEncodedNumbers = JSON.stringify(numberData),
    msgpackEncodedStrings = packer.pack(stringData),
    msgpackEncodedNumbers = packer.pack(numberData);
Tests:
  • MsgPack Strings Encode

     
    var result = packer.pack(stringData);
  • JSON Strings Encode

     
    var result = JSON.stringify(stringData);
  • MsgPack Numbers Encode

     
    var result = packer.pack(numberData);
  • JSON Numbers Encode

     
    var result = JSON.stringify(numberData);
  • MsgPack Numbers Decode

     
    var result = packer.unpack(msgpackEncodedNumbers);
  • JSON Numbers Decode

     
    var result = JSON.parse(jsonEncodedNumbers);
  • JSON String Decode

     
    var result = JSON.parse(jsonEncodedStrings);
  • MsgPack String Decode

     
    var result = packer.unpack(msgpackEncodedStrings);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    MsgPack Strings Encode
    JSON Strings Encode
    MsgPack Numbers Encode
    JSON Numbers Encode
    MsgPack Numbers Decode
    JSON Numbers Decode
    JSON String Decode
    MsgPack String Decode

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one month ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Chrome 133 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
MsgPack Strings Encode 1145799.6 Ops/sec
JSON Strings Encode 2472829.5 Ops/sec
MsgPack Numbers Encode 1325743.9 Ops/sec
JSON Numbers Encode 1715999.8 Ops/sec
MsgPack Numbers Decode 1945298.2 Ops/sec
JSON Numbers Decode 1598824.6 Ops/sec
JSON String Decode 1507480.2 Ops/sec
MsgPack String Decode 1934553.1 Ops/sec