Msgpack-js vs JSON (v35)

Revision 35 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://rawgit.com/msgpack/msgpack-javascript/master/msgpack.js"></script>

Setup

var stringData = {"key1":"select country_code,country_name,region_name,city_name,latitude,longitude,zip_code,time_zone from ip2location where ip_from = ( SELECT max(ip_from) FROM i)","key2":"select country_code,country_name,region_name,city_name,latitude,longitude,zip_code,time_zone from ip2location where ip_from = ( SELECT max(ip_from) FROM i)","key3":"select country_code,country_name,region_name,city_name,latitude,longitude,zip_code,time_zone from ip2location where ip_from = ( SELECT max(ip_from) FROM i)","key4":"select country_code,country_name,region_name,city_name,latitude,longitude,zip_code,time_zone from ip2location where ip_from = ( SELECT max(ip_from) FROM i)","key5":"select country_code,country_name,region_name,city_name,latitude,longitude,zip_code,time_zone from ip2location where ip_from = ( SELECT max(ip_from) FROM i)"};
    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.unpack(msgpack.pack(stringData));
ready
MsgPack numbers
var result = msgpack.unpack(msgpack.pack(numberData));
ready

Revisions

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