diff --git a/.gitignore b/.gitignore index 16c7f97..28d92e6 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,6 @@ node_modules/ .vscode/ # Project -tmp/ /.local/ /media/ /img/ diff --git a/README.md b/README.md index 26739e3..1ac296c 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ This article will mostly focus on the performance aspect and provide a brief ove To reproduce the benchmark results, follow these steps. -* Install Node.js ( `12.18.3 LTS` is recommended). +* Install Node.js ( `14 LTS` is requirement). * Install dependencies: ```shell script @@ -196,7 +196,7 @@ This is investigated in an additional result section that is found after the mai ### Hardware -The benchmark is done in Node.js v12.16.3 on 64-bit Windows 10, with an Intel i7-4790K 4.00GHz CPU and 16 GB RAM. +The benchmark is done in Node.js v12.16.3 on 64-bit Windows 10, with an Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz and 32 GB RAM(Speed: 2667 MT/s). ## Result (Protocol Buffers) @@ -241,7 +241,7 @@ All implementations (`protobuf-js`, `pbf`, `protons`, `google-protobuf`) stayed This is a ranking of the estimated maximum safe payload limit (measured as JSON) each library was able to process: 1. `pbf`, `mixed`: 372 MB -2. `JSON`: 298 MB +2. `JSON`, `V8`, `MsgPack`: 298 MB 3. `protobuf-js`: 153 MB 4. `google-protobuf`: 98 MB 5. `protons`: 40 MB @@ -250,7 +250,7 @@ This is a ranking of the estimated maximum safe payload limit (measured as JSON) ### Negative effects during decoding -| |JSON|JS|Google|Protons|Pbf|mixed +| |JSON, V8, MsgPack|JS|Google|Protons|Pbf|mixed |---|---|---|---|---|---|--- |Prototype pollution | |x| |x| |x |Getters/Setters| | | |x| | | diff --git a/img/bench-avro-extra.svg b/img/bench-avro-extra.svg index 9de0fbd..088c481 100644 --- a/img/bench-avro-extra.svg +++ b/img/bench-avro-extra.svg @@ -3,10 +3,22 @@ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> + + + + + 2020-10-05T09:50:13.199744 + image/svg+xml + + + Matplotlib v3.3.2, https://matplotlib.org/ + + + + + - + @@ -29,7 +41,7 @@ z - @@ -37,16 +49,17 @@ L 166.951075 35.856 +" id="mfe38ac5f8f" style="stroke:#000000;stroke-width:0.8;"/> - + - - + + - - - + @@ -90,13 +102,13 @@ z - - + @@ -110,19 +122,20 @@ L 358.718932 35.856 - - + - - + + - - + @@ -159,178 +171,179 @@ z +" id="m343a095122" style="stroke:#000000;stroke-width:0.6;"/> - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - - - - - + - - - - - - - - - + @@ -576,140 +588,120 @@ z - +" id="m63af53ee5f" style="stroke:#000000;stroke-width:0.8;"/> - + - - - - - - + + - - - - - + - - - - - - + + + - - + - - - - - - - - - + + + - - + - - - - - - + + + + + + - - + + - - - - - - - - - - + @@ -933,217 +924,303 @@ z - - - - - + + + + + + - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - - + + - - + + - - - + @@ -1269,16 +1494,17 @@ z - - + + - - + + - - + + - - - - - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - + + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + @@ -1433,17 +1649,17 @@ z - - + - + - + - + @@ -1453,17 +1669,17 @@ L 166.951075 161.352 - - + - + - + - + @@ -1473,17 +1689,17 @@ L 358.718932 161.352 - - + - + - + - + @@ -1493,174 +1709,174 @@ L 550.486789 161.352 - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1682,19 +1898,27 @@ L 550.486789 161.352 - - + - + - + - + - + + + + @@ -1702,19 +1926,45 @@ L 648 263.448106 - - + - + - + - + - + + + + @@ -1722,29 +1972,70 @@ L 648 221.61631 - - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + @@ -1785,218 +2075,304 @@ z - - + - - + - - + - - + - - + + + + + + + + - + diff --git a/img/bench-bson-extra.svg b/img/bench-bson-extra.svg index 8b4a8fa..b8e2ba1 100644 --- a/img/bench-bson-extra.svg +++ b/img/bench-bson-extra.svg @@ -3,10 +3,22 @@ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> + + + + + 2020-10-05T09:50:13.553199 + image/svg+xml + + + Matplotlib v3.3.2, https://matplotlib.org/ + + + + + - + @@ -29,7 +41,7 @@ z - @@ -37,16 +49,17 @@ L 166.951075 35.856 +" id="md3d4c18191" style="stroke:#000000;stroke-width:0.8;"/> - + - - + + - - - + @@ -90,13 +102,13 @@ z - - + @@ -110,19 +122,20 @@ L 358.718932 35.856 - - + - - + + - - + @@ -159,178 +171,179 @@ z +" id="m0166766a5a" style="stroke:#000000;stroke-width:0.6;"/> - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - - - - - + - - - - - - - - - + @@ -576,60 +588,61 @@ z - +" id="m71a14be17e" style="stroke:#000000;stroke-width:0.8;"/> - + - + - - + - + - - + - - + + - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - - - - - - - - - + @@ -893,153 +986,239 @@ z - - + - - + - - + - - + + + + + + + - - - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - - + + - - + + - - - + @@ -1165,45 +1492,45 @@ z - - + + - - + + - + - - - + + + - - + + - - + + - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + @@ -1219,17 +1546,17 @@ z - - + - + - + - + @@ -1239,17 +1566,17 @@ L 166.951075 161.352 - - + - + - + - + @@ -1259,17 +1586,17 @@ L 358.718932 161.352 - - + - + - + - + @@ -1279,174 +1606,174 @@ L 550.486789 161.352 - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1467,102 +1794,47 @@ L 550.486789 161.352 - - - - - - - - - - - - - - - - - - - - - - - - - + + - + - + - - - + + + - - - - - + + - + - + - - - - - - + + + + - + - - + + - - + @@ -1603,153 +1874,239 @@ z - - + - - + - - + - - + + + + + + + + - + diff --git a/img/bench-full.svg b/img/bench-full.svg index 5d8adc1..9b789e8 100644 --- a/img/bench-full.svg +++ b/img/bench-full.svg @@ -3,10 +3,22 @@ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> + + + + + 2020-10-05T09:50:11.323709 + image/svg+xml + + + Matplotlib v3.3.2, https://matplotlib.org/ + + + + + - + @@ -29,7 +41,7 @@ z - @@ -37,16 +49,17 @@ L 166.951075 73.44 +" id="mf1b8a9b20d" style="stroke:#000000;stroke-width:0.8;"/> - + - - + + - - - + @@ -90,13 +102,13 @@ z - - + @@ -110,19 +122,20 @@ L 358.718932 73.44 - - + - - + + - - + @@ -159,178 +171,179 @@ z +" id="m22c23f4297" style="stroke:#000000;stroke-width:0.6;"/> - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - - - - - + - - - - - - - - - + @@ -576,414 +588,63 @@ z - +" id="me307b69be6" style="stroke:#000000;stroke-width:0.8;"/> - + - - - + + - - - + - + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + - - - - - - - - + @@ -1154,334 +814,420 @@ z - - + - - + - - + - - + - - + - - + - - + - - + + + + + + + - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - + - - + + - - + @@ -1556,16 +1482,17 @@ z - - + + - + - - + + - - - - - + - - - - - - - - - - - - + + + + + + + + + + + + - + - + - - - + + + - - + + - + - + - - - + + + - - + + - - - - - - + + + + + - - - - + @@ -1748,16 +1646,17 @@ z - - + + - + - - + + - - - + @@ -1818,16 +1716,17 @@ z - - + + - + - - + + - - + @@ -1855,8 +1753,8 @@ z - - + + @@ -1872,14 +1770,14 @@ z - - + - + - + @@ -1892,14 +1790,14 @@ L 166.951075 196.372174 - - + - + - + @@ -1912,14 +1810,14 @@ L 358.718932 196.372174 - - + - + - + @@ -1932,170 +1830,170 @@ L 550.486789 196.372174 - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2120,93 +2018,58 @@ L 550.486789 196.372174 - - - + + - + - + - + - - - + + - + - + - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - + + - + - + - + - - + + - - + - + - - + + - - - + @@ -2304,334 +2134,420 @@ z - - + - - + - - + - - + - - + - - + - - + - - + + + + + + + - - + - + - + - + @@ -2685,17 +2601,17 @@ L 166.951075 319.304348 - - + - + - + - + @@ -2705,17 +2621,17 @@ L 358.718932 319.304348 - - + - + - + - + @@ -2725,174 +2641,174 @@ L 550.486789 319.304348 - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2913,20 +2829,20 @@ L 550.486789 319.304348 - - - + + - + - + - + - + @@ -2934,30 +2850,31 @@ L 648 384.837178 - - - + + - + - + - + - + - + - - + + - - + @@ -2994,334 +2910,420 @@ z - - + - - + - - + - - + - - + - - + - - + - - + + + + + + + - - + - + - + - + @@ -3375,17 +3377,17 @@ L 166.951075 442.236522 - - + - + - + - + @@ -3395,17 +3397,17 @@ L 358.718932 442.236522 - - + - + - + - + @@ -3415,174 +3417,174 @@ L 550.486789 442.236522 - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -3603,79 +3605,61 @@ L 550.486789 442.236522 - - - + + - + - + - + - + - - - - - - - - - - - - - - - - - - - + + - + - + - + - + - - - + + - + - + - - - - + + + + - + @@ -3700,334 +3684,420 @@ L 648 453.539812 - - + - - + - - + - - + - - + - - + - - + - - + + + + + + + + - + - + - + diff --git a/img/bench-jsbin-extra.svg b/img/bench-jsbin-extra.svg index 69bd52f..1587699 100644 --- a/img/bench-jsbin-extra.svg +++ b/img/bench-jsbin-extra.svg @@ -3,10 +3,22 @@ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> + + + + + 2020-10-05T09:50:13.896821 + image/svg+xml + + + Matplotlib v3.3.2, https://matplotlib.org/ + + + + + - + @@ -29,7 +41,7 @@ z - @@ -37,16 +49,17 @@ L 166.951075 35.856 +" id="m79e9b785f1" style="stroke:#000000;stroke-width:0.8;"/> - + - - + + - - - + @@ -90,13 +102,13 @@ z - - + @@ -110,19 +122,20 @@ L 358.718932 35.856 - - + - - + + - - + @@ -159,178 +171,179 @@ z +" id="m9b39acda4b" style="stroke:#000000;stroke-width:0.6;"/> - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - - - - - + - - - - - - - - - + @@ -576,161 +588,102 @@ z - +" id="m0db9534a00" style="stroke:#000000;stroke-width:0.8;"/> - + - - - - - - - - - - + + + - - + - - - - - - + + + - - + - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - +" id="DejaVuSans-51"/> + + - - - - - - - - - - - - - - - - - - - - + - - + + - - - - - - - - - - + @@ -953,263 +905,349 @@ z - - + - - + - - + - - + - - + - - + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - + - - + + - - - + @@ -1335,23 +1521,23 @@ z - - + + - + - - + + - - + @@ -1359,23 +1545,23 @@ z - - + + - + - - + + - - + @@ -1394,15 +1580,15 @@ z - - + + - + - + @@ -1421,15 +1607,15 @@ L 447.165625 9.214038 - - + + - + - + @@ -1466,14 +1652,14 @@ z - - + - + - + @@ -1486,14 +1672,14 @@ L 166.951075 161.352 - - + - + - + @@ -1506,14 +1692,14 @@ L 358.718932 161.352 - - + - + - + @@ -1526,170 +1712,170 @@ L 550.486789 161.352 - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1714,115 +1900,145 @@ L 550.486789 161.352 - - - + + - + - + - - + + + + + - - - - + + - + - + - - + + + + + - - + - - - + + - + - + - - - + + + - - + - - - + + - + - + - - - + + + - - + - - - + + - + - + - - - + + + - - - + + - - + @@ -1863,263 +2078,349 @@ z - - + - - + - - + - - + - - + - - + + + + + + + + - + diff --git a/img/bench-json-extra.svg b/img/bench-json-extra.svg index 45732f6..c457ccc 100644 --- a/img/bench-json-extra.svg +++ b/img/bench-json-extra.svg @@ -3,10 +3,22 @@ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> + + + + + 2020-10-05T09:50:12.830445 + image/svg+xml + + + Matplotlib v3.3.2, https://matplotlib.org/ + + + + + - + @@ -29,7 +41,7 @@ z - @@ -37,16 +49,17 @@ L 166.951075 35.856 +" id="m8244564dc5" style="stroke:#000000;stroke-width:0.8;"/> - + - - + + - - - + @@ -90,13 +102,13 @@ z - - + @@ -110,19 +122,20 @@ L 358.718932 35.856 - - + - - + + - - + @@ -159,178 +171,179 @@ z +" id="m1d5abdc0f6" style="stroke:#000000;stroke-width:0.6;"/> - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - - - - - + - - - - - - - - - + @@ -576,30 +588,70 @@ z - +" id="m387070aa03" style="stroke:#000000;stroke-width:0.8;"/> - + - - - + + - + + + + + + + + + + + + + + + + + + + + + - - + - - - - - - - - - - - - - - - - - - - - - - - + - - + + - - + @@ -731,80 +751,49 @@ z - - + - - - - - - + + + - + - - + - - + + - + - - + + - - - - - - - - - - + @@ -1028,89 +1016,89 @@ z - - @@ -1170,8 +1158,9 @@ L 330.3125 23.892163 - - + + - - - + @@ -1251,13 +1239,13 @@ z - - + @@ -1271,13 +1259,13 @@ L 166.951075 161.352 - - + @@ -1291,13 +1279,13 @@ L 358.718932 161.352 - - + @@ -1312,168 +1300,168 @@ L 550.486789 161.352 - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1500,107 +1488,69 @@ L 550.486789 161.352 - - + - - - - - + + - + - - + - - + + - + - - + - - - - - - - - - - - - - - - - - - - + - + - - + + - - + @@ -1641,90 +1590,90 @@ z - - + - - + @@ -1750,10 +1699,10 @@ L 648 161.352 - + - + diff --git a/img/bench-protobuf.svg b/img/bench-protobuf.svg index fd22a1b..1db1e84 100644 --- a/img/bench-protobuf.svg +++ b/img/bench-protobuf.svg @@ -3,10 +3,22 @@ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> + + + + + 2020-10-05T09:50:12.099649 + image/svg+xml + + + Matplotlib v3.3.2, https://matplotlib.org/ + + + + + - + @@ -29,7 +41,7 @@ z - @@ -37,16 +49,17 @@ L 166.951075 73.44 +" id="mf887ee80cb" style="stroke:#000000;stroke-width:0.8;"/> - + - - + + - - - + @@ -90,13 +102,13 @@ z - - + @@ -110,19 +122,20 @@ L 358.718932 73.44 - - + - - + + - - + @@ -159,178 +171,179 @@ z +" id="m52d9b2be6f" style="stroke:#000000;stroke-width:0.6;"/> - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - - - - - + - - - - - - - - - + @@ -576,31 +588,31 @@ z - +" id="m90e2f6d9d3" style="stroke:#000000;stroke-width:0.8;"/> - + - - + + - - + @@ -610,18 +622,18 @@ z - - + - + @@ -631,18 +643,18 @@ L 648 125.658434 - - + - + @@ -651,216 +663,258 @@ L 648 97.341352 - - - + + + - + + + + + + + + + - + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + - + - + + + + + + + + + + + + + + + - - + + - - - - - - - - + @@ -1031,246 +1084,332 @@ z - - + - - + - - + - - + - - + - - + + + + + + + - - - + - - - - - - - - + + + + + + + + + + - - + - - - - - + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + @@ -1429,16 +1729,17 @@ z - - + + - - + + - - + + - - - + @@ -1499,16 +1799,17 @@ z - - + + - - + + - - + + - - + @@ -1536,24 +1836,25 @@ z - - - - - - + + + + + + - - + + - - + + - - + + - - - - + @@ -1636,16 +1903,17 @@ z - - + + - - + + - - + + - - + @@ -1673,8 +1940,8 @@ z - - + + @@ -1690,17 +1957,17 @@ z - - + - + - + - + @@ -1710,17 +1977,17 @@ L 166.951075 196.372174 - - + - + - + - + @@ -1730,17 +1997,17 @@ L 358.718932 196.372174 - - + - + - + - + @@ -1750,174 +2017,174 @@ L 550.486789 196.372174 - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1938,109 +2205,40 @@ L 550.486789 196.372174 - - - - - - - - - - - - - - - - - - - + + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - + + - + - + - + - - + + - - + - - - - + + + + + + + + + + + + + - +" id="DejaVuSans-54"/> + + + + + + + @@ -2122,246 +2335,332 @@ z - - + - - + - - + - - + - - + - - + + + + + + + - - + - + - + - + @@ -2415,17 +2714,17 @@ L 166.951075 319.304348 - - + - + - + - + @@ -2435,17 +2734,17 @@ L 358.718932 319.304348 - - + - + - + - + @@ -2455,174 +2754,174 @@ L 550.486789 319.304348 - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2643,20 +2942,20 @@ L 550.486789 319.304348 - - - + + - + - + - + - + @@ -2664,30 +2963,31 @@ L 648 393.523323 - - - + + - + - + - + - + - + - - + + - - + @@ -2724,246 +3023,332 @@ z - - + - - + - - + - - + - - + - - + + + + + + + - - + - + - + - + @@ -3017,17 +3402,17 @@ L 166.951075 442.236522 - - + - + - + - + @@ -3037,17 +3422,17 @@ L 358.718932 442.236522 - - + - + - + - + @@ -3057,174 +3442,174 @@ L 550.486789 442.236522 - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -3245,82 +3630,116 @@ L 550.486789 442.236522 - - - + + - + - + - + - + - - - + + - + - + - + - + - - - + + - + - + - + - + - - - + + - + - + - + - + + + + - + @@ -3345,246 +3764,332 @@ L 648 443.157727 - - + - - + - - + - - + - - + - - + + + + + + + + - + - + - + diff --git a/package.json b/package.json index a9351d5..fea2ce8 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,9 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "sideEffects": false, + "engines": { + "node": ">=14" + }, "scripts": { "clean": "rimraf dist dist-minified coverage tmp", "start": "ts-node src/index.ts --expose-gc", @@ -30,6 +33,7 @@ "postversion": "git push && git push --tags" }, "dependencies": { + "@msgpack/msgpack": "^2.2.0", "avro-js": "^1.10.0", "avsc": "^5.4.21", "bser": "^2.1.1", diff --git a/src/benchmarks.ts b/src/benchmarks.ts index 5c0be80..e5df33e 100644 --- a/src/benchmarks.ts +++ b/src/benchmarks.ts @@ -1,3 +1,4 @@ +import v8 from 'v8'; import avro from 'avro-js'; import avsc from 'avsc'; import BSON from 'bson'; @@ -5,6 +6,7 @@ import fs from 'fs'; import JsBin from 'js-binary'; import Pbf from 'pbf'; import protobufJs from 'protobufjs'; +import * as msgpack from "@msgpack/msgpack"; import protons from 'protons'; import { ROOT_DIR } from './_root'; import ProtoGoogleSchema from './data/google-protobuf_pb'; @@ -32,6 +34,42 @@ export function testJsonUnmapped(testData: any): Promise { }); } +export function testV8(testData: any): Promise { + return benchmark({ + data: testData, + encode: data => v8.serialize(data), + decode: data => v8.deserialize(data), + sampleDecoded: data => data.items[0], + }); +} + +export function testV8Unmapped(testData: any): Promise { + return benchmark({ + data: testData, + encode: data => JSON.stringify(data), + decode: data => JSON.parse(data), + sampleDecoded: data => data[0], + }); +} + +export function testMsgPack(testData: any): Promise { + return benchmark({ + data: testData, + encode: data => msgpack.encode(data), + decode: data => msgpack.decode(data), + sampleDecoded: data => data.items[0], + }); +} + +export function testMsgPackUnmapped(testData: any): Promise { + return benchmark({ + data: testData, + encode: data => msgpack.encode(data), + decode: data => msgpack.decode(data), + sampleDecoded: data => data[0], + }); +} + function createAvroSchemaBase(): any { return { name: 'items', diff --git a/src/index.ts b/src/index.ts index 33faeba..28ef683 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,6 +4,8 @@ import { runTest } from './utils/helper'; const TESTS = { testJson: () => runTest('JSON', ({ data }) => bench.testJson(data), 298), + testV8: () => runTest('V8', ({ data }) => bench.testV8(data), 298), + testMsgPack: () => runTest('MsgPack', ({ data }) => bench.testMsgPack(data), 298), testBson: () => runTest('BSON', ({ data }) => bench.testBson(data), 21), @@ -48,6 +50,8 @@ const TESTS = { async function runDefault() { console.log('Running default'); await TESTS.testJson(); + await TESTS.testV8(); + await TESTS.testMsgPack(); await TESTS.testBson(); diff --git a/src/plot.py b/src/plot.py index b9eba8d..9a6ab8a 100644 --- a/src/plot.py +++ b/src/plot.py @@ -34,6 +34,8 @@ def main(): # Main test OUTPUT_NAME='bench-full.svg' ALLOWED_LABELS = [ + "V8", + "MsgPack", "JSON", "JSBIN", "AVRO Avsc", @@ -49,6 +51,8 @@ def main(): # Protocol buffers OUTPUT_NAME='bench-protobuf.svg' ALLOWED_LABELS = [ + "V8", + "MsgPack", "JSON", "PROTOBUF JS", "PROTOBUF Pbf", @@ -73,6 +77,8 @@ def main(): # Avro extra OUTPUT_NAME='bench-avro-extra.svg' ALLOWED_LABELS = [ + "V8", + "MsgPack", "JSON", "JSON (unmapped)", "AVRO Avsc", @@ -84,6 +90,8 @@ def main(): # BSON extra OUTPUT_NAME='bench-bson-extra.svg' ALLOWED_LABELS = [ + "V8", + "MsgPack", "JSON", "JSON (unmapped)", "BSON", @@ -94,6 +102,8 @@ def main(): # JSBIN extra OUTPUT_NAME='bench-jsbin-extra.svg' ALLOWED_LABELS = [ + "V8", + "MsgPack", "JSON", "JSON (unmapped)", "JSBIN", diff --git a/src/run-tests.sh b/src/run-tests.sh old mode 100644 new mode 100755 index 21d18ce..6af5488 --- a/src/run-tests.sh +++ b/src/run-tests.sh @@ -2,6 +2,10 @@ npm start 'testJson' +npm start 'testMsgPack' + +npm start 'testV8' + npm start 'testBson' npm start 'testAvroJs' diff --git a/src/tmp/.gitignore b/src/tmp/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/src/tmp/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore