High performance JSON serialization and deserialization library for JavaScript, Node.js, browser.
json-pack
contains implementations of various JSON codecs into binary,
formats, such as MessagePack, CBOR and other formats.
- MessagePack
- CBOR
- DAG-CBOR
- JSON
- DAG-JSON
- UBJSON
- Amazon Ion
- RESP3
- Bencode
Encoding:
npx ts-node benchmarks/json-pack/bench.encoding.ts
=============================================================================== Benchmark: Encoding
Warmup: 1000x , Node.js: v20.0.0 , Arch: arm64 , CPU: Apple M1
---------------------------------------------------------------------------- Small object, 44 bytes
π€ json-pack JsonEncoder x 5,385,617 ops/sec Β±0.53% (100 runs sampled)
π€ Buffer.from(JSON.stringify()) x 2,254,954 ops/sec Β±0.83% (97 runs sampled)
π€ json-pack CborEncoderFast x 5,953,159 ops/sec Β±1.12% (92 runs sampled)
π€ json-pack CborEncoder x 6,248,036 ops/sec Β±0.29% (98 runs sampled)
π€ json-pack MsgPackEncoderFast x 3,121,940 ops/sec Β±0.16% (99 runs sampled)
π€ JSON.stringify() x 3,866,116 ops/sec Β±0.11% (101 runs sampled)
π€ @msgpack/msgpack x 1,406,546 ops/sec Β±0.94% (93 runs sampled)
π€ msgpackr x 2,404,916 ops/sec Β±3.22% (86 runs sampled)
π€ cbor-x x 4,737,433 ops/sec Β±1.00% (97 runs sampled)
π€ msgpack-lite x 987,201 ops/sec Β±2.84% (91 runs sampled)
π€ msgpack5 x 197,867 ops/sec Β±3.65% (84 runs sampled)
π€ messagepack x 171,865 ops/sec Β±4.44% (74 runs sampled)
Fastest is π€ json-pack CborEncoder
------------------------------------------------------------------------- Typical object, 993 bytes
π€ json-pack JsonEncoder x 299,970 ops/sec Β±0.30% (97 runs sampled)
π€ Buffer.from(JSON.stringify()) x 211,651 ops/sec Β±0.18% (100 runs sampled)
π€ json-pack CborEncoderFast x 429,535 ops/sec Β±3.38% (93 runs sampled)
π€ json-pack CborEncoder x 428,848 ops/sec Β±0.71% (97 runs sampled)
π€ json-pack MsgPackEncoderFast x 322,982 ops/sec Β±0.67% (97 runs sampled)
π€ JSON.stringify() x 306,828 ops/sec Β±1.94% (90 runs sampled)
π€ @msgpack/msgpack x 199,937 ops/sec Β±5.52% (93 runs sampled)
π€ msgpackr x 317,457 ops/sec Β±2.18% (90 runs sampled)
π€ cbor-x x 401,854 ops/sec Β±3.20% (92 runs sampled)
π€ msgpack-lite x 135,110 ops/sec Β±1.29% (94 runs sampled)
π€ msgpack5 x 15,217 ops/sec Β±3.72% (85 runs sampled)
π€ messagepack x 13,853 ops/sec Β±4.73% (71 runs sampled)
Fastest is π€ json-pack CborEncoder
-------------------------------------------------------------------------- Large object, 3741 bytes
π€ json-pack JsonEncoder x 87,312 ops/sec Β±1.10% (96 runs sampled)
π€ Buffer.from(JSON.stringify()) x 64,718 ops/sec Β±0.45% (96 runs sampled)
π€ json-pack CborEncoderFast x 134,615 ops/sec Β±0.19% (97 runs sampled)
π€ json-pack CborEncoder x 128,975 ops/sec Β±0.20% (98 runs sampled)
π€ json-pack MsgPackEncoderFast x 103,325 ops/sec Β±1.62% (98 runs sampled)
π€ JSON.stringify() x 101,067 ops/sec Β±1.36% (95 runs sampled)
π€ @msgpack/msgpack x 61,715 ops/sec Β±0.22% (98 runs sampled)
π€ msgpackr x 95,175 ops/sec Β±3.84% (95 runs sampled)
π€ cbor-x x 111,658 ops/sec Β±1.34% (95 runs sampled)
π€ msgpack-lite x 41,364 ops/sec Β±0.28% (100 runs sampled)
π€ msgpack5 x 3,262 ops/sec Β±4.32% (71 runs sampled)
π€ messagepack x 4,167 ops/sec Β±7.29% (65 runs sampled)
Fastest is π€ json-pack CborEncoderFast
-------------------------------------------------------------------- Very large object, 45750 bytes
π€ json-pack JsonEncoder x 5,687 ops/sec Β±1.92% (94 runs sampled)
π€ Buffer.from(JSON.stringify()) x 5,813 ops/sec Β±2.51% (97 runs sampled)
π€ json-pack CborEncoderFast x 5,749 ops/sec Β±0.67% (98 runs sampled)
π€ json-pack CborEncoder x 5,515 ops/sec Β±0.70% (98 runs sampled)
π€ json-pack MsgPackEncoderFast x 5,027 ops/sec Β±0.19% (100 runs sampled)
π€ JSON.stringify() x 7,687 ops/sec Β±0.87% (99 runs sampled)
π€ @msgpack/msgpack x 3,379 ops/sec Β±2.20% (97 runs sampled)
π€ msgpackr x 5,929 ops/sec Β±15.26% (96 runs sampled)
π€ cbor-x x 5,032 ops/sec Β±5.17% (90 runs sampled)
π€ msgpack-lite x 2,173 ops/sec Β±1.17% (97 runs sampled)
π€ msgpack5 x 179 ops/sec Β±2.95% (68 runs sampled)
π€ messagepack x 167 ops/sec Β±1.09% (79 runs sampled)
Fastest is π€ JSON.stringify()
------------------------------------------------------------------ Object with many keys, 969 bytes
π€ json-pack JsonEncoder x 213,447 ops/sec Β±3.31% (95 runs sampled)
π€ Buffer.from(JSON.stringify()) x 168,303 ops/sec Β±2.13% (95 runs sampled)
π€ json-pack CborEncoderFast x 275,511 ops/sec Β±0.40% (95 runs sampled)
π€ json-pack CborEncoder x 270,949 ops/sec Β±0.32% (97 runs sampled)
π€ json-pack MsgPackEncoderFast x 210,525 ops/sec Β±0.66% (99 runs sampled)
π€ JSON.stringify() x 200,767 ops/sec Β±0.19% (101 runs sampled)
π€ @msgpack/msgpack x 163,665 ops/sec Β±0.81% (98 runs sampled)
π€ msgpackr x 151,889 ops/sec Β±0.27% (96 runs sampled)
π€ cbor-x x 191,010 ops/sec Β±0.44% (96 runs sampled)
π€ msgpack-lite x 93,537 ops/sec Β±0.68% (99 runs sampled)
π€ msgpack5 x 28,581 ops/sec Β±1.74% (93 runs sampled)
π€ messagepack x 8,330 ops/sec Β±5.00% (61 runs sampled)
Fastest is π€ json-pack CborEncoderFast
------------------------------------------------------------------------- String ladder, 3398 bytes
π€ json-pack JsonEncoder x 147,755 ops/sec Β±0.23% (97 runs sampled)
π€ Buffer.from(JSON.stringify()) x 128,378 ops/sec Β±0.15% (96 runs sampled)
π€ json-pack CborEncoderFast x 298,037 ops/sec Β±0.73% (98 runs sampled)
π€ json-pack CborEncoder x 293,608 ops/sec Β±0.22% (97 runs sampled)
π€ json-pack MsgPackEncoderFast x 244,864 ops/sec Β±3.92% (92 runs sampled)
π€ JSON.stringify() x 165,819 ops/sec Β±1.72% (94 runs sampled)
π€ @msgpack/msgpack x 79,127 ops/sec Β±1.43% (93 runs sampled)
π€ msgpackr x 236,254 ops/sec Β±1.45% (94 runs sampled)
π€ cbor-x x 206,835 ops/sec Β±1.26% (92 runs sampled)
π€ msgpack-lite x 157,499 ops/sec Β±0.39% (98 runs sampled)
π€ msgpack5 x 55,363 ops/sec Β±2.75% (88 runs sampled)
π€ messagepack x 8,261 ops/sec Β±2.97% (72 runs sampled)
Fastest is π€ json-pack CborEncoderFast
-------------------------------------------------------------------------- Long strings, 7011 bytes
π€ json-pack JsonEncoder x 51,334 ops/sec Β±0.16% (99 runs sampled)
π€ Buffer.from(JSON.stringify()) x 27,108 ops/sec Β±4.89% (90 runs sampled)
π€ json-pack CborEncoderFast x 374,042 ops/sec Β±6.39% (91 runs sampled)
π€ json-pack CborEncoder x 424,864 ops/sec Β±0.35% (97 runs sampled)
π€ json-pack MsgPackEncoderFast x 363,465 ops/sec Β±1.91% (85 runs sampled)
π€ JSON.stringify() x 59,793 ops/sec Β±0.14% (100 runs sampled)
π€ @msgpack/msgpack x 57,373 ops/sec Β±0.13% (98 runs sampled)
π€ msgpackr x 372,751 ops/sec Β±2.17% (90 runs sampled)
π€ cbor-x x 389,277 ops/sec Β±1.60% (93 runs sampled)
π€ msgpack-lite x 170,279 ops/sec Β±0.82% (97 runs sampled)
π€ msgpack5 x 83,809 ops/sec Β±2.80% (83 runs sampled)
π€ messagepack x 20,076 ops/sec Β±1.45% (87 runs sampled)
Fastest is π€ json-pack CborEncoder
-------------------------------------------------------------------------- Short strings, 170 bytes
π€ json-pack JsonEncoder x 1,577,757 ops/sec Β±0.16% (98 runs sampled)
π€ Buffer.from(JSON.stringify()) x 1,057,420 ops/sec Β±0.38% (100 runs sampled)
π€ json-pack CborEncoderFast x 1,844,775 ops/sec Β±0.20% (100 runs sampled)
π€ json-pack CborEncoder x 1,468,011 ops/sec Β±0.23% (98 runs sampled)
π€ json-pack MsgPackEncoderFast x 1,240,577 ops/sec Β±0.19% (98 runs sampled)
π€ JSON.stringify() x 1,852,916 ops/sec Β±0.20% (100 runs sampled)
π€ @msgpack/msgpack x 781,414 ops/sec Β±0.42% (92 runs sampled)
π€ msgpackr x 1,672,474 ops/sec Β±0.23% (99 runs sampled)
π€ cbor-x x 1,351,338 ops/sec Β±0.20% (97 runs sampled)
π€ msgpack-lite x 416,300 ops/sec Β±0.76% (96 runs sampled)
π€ msgpack5 x 151,657 ops/sec Β±1.97% (91 runs sampled)
π€ messagepack x 35,124 ops/sec Β±5.60% (61 runs sampled)
Fastest is π€ JSON.stringify()
-------------------------------------------------------------------------------- Numbers, 136 bytes
π€ json-pack JsonEncoder x 1,708,133 ops/sec Β±1.09% (98 runs sampled)
π€ Buffer.from(JSON.stringify()) x 1,135,630 ops/sec Β±1.67% (95 runs sampled)
π€ json-pack CborEncoderFast x 2,658,037 ops/sec Β±1.33% (97 runs sampled)
π€ json-pack CborEncoder x 3,084,914 ops/sec Β±0.24% (101 runs sampled)
π€ json-pack MsgPackEncoderFast x 1,620,958 ops/sec Β±2.15% (94 runs sampled)
π€ JSON.stringify() x 1,602,303 ops/sec Β±0.24% (98 runs sampled)
π€ @msgpack/msgpack x 997,885 ops/sec Β±1.70% (97 runs sampled)
π€ msgpackr x 2,659,862 ops/sec Β±0.51% (96 runs sampled)
π€ cbor-x x 3,116,954 ops/sec Β±0.89% (95 runs sampled)
π€ msgpack-lite x 892,281 ops/sec Β±2.19% (92 runs sampled)
π€ msgpack5 x 144,567 ops/sec Β±3.06% (88 runs sampled)
π€ messagepack x 383,134 ops/sec Β±2.95% (74 runs sampled)
Fastest is π€ cbor-x
--------------------------------------------------------------------------------- Tokens, 308 bytes
π€ json-pack JsonEncoder x 1,370,517 ops/sec Β±0.52% (98 runs sampled)
π€ Buffer.from(JSON.stringify()) x 1,016,856 ops/sec Β±0.16% (93 runs sampled)
π€ json-pack CborEncoderFast x 1,347,193 ops/sec Β±0.20% (96 runs sampled)
π€ json-pack CborEncoder x 1,353,358 ops/sec Β±0.20% (101 runs sampled)
π€ json-pack MsgPackEncoderFast x 1,130,418 ops/sec Β±0.14% (96 runs sampled)
π€ JSON.stringify() x 1,549,669 ops/sec Β±0.49% (97 runs sampled)
π€ @msgpack/msgpack x 871,477 ops/sec Β±0.92% (98 runs sampled)
π€ msgpackr x 1,716,378 ops/sec Β±0.20% (99 runs sampled)
π€ cbor-x x 1,951,639 ops/sec Β±0.16% (100 runs sampled)
π€ msgpack-lite x 622,495 ops/sec Β±1.03% (96 runs sampled)
π€ msgpack5 x 81,727 ops/sec Β±2.04% (91 runs sampled)
π€ messagepack x 609,651 ops/sec Β±1.64% (89 runs sampled)
Fastest is π€ cbor-x
Decoding:
node benchmarks/json-pack/bench.decoding.js
=============================================================================== Benchmark: Decoding
Warmup: 1000x , Node.js: v16.14.2 , Arch: arm64 , CPU: Apple M1
-------------------------------------------------------------------- Very large object, 45750 bytes
π JSON.parse() x 3,506 ops/sec Β±0.19% (100 runs sampled)
π sjson.parse() x 3,336 ops/sec Β±0.11% (99 runs sampled)
π json-pack CborDecoderBase x 4,915 ops/sec Β±0.18% (100 runs sampled)
π cbor-x x 4,747 ops/sec Β±0.15% (100 runs sampled)
π cbor x 260 ops/sec Β±0.29% (90 runs sampled)
π json-pack MsgPackDecoderFast x 5,506 ops/sec Β±0.48% (100 runs sampled)
π msgpackr x 4,729 ops/sec Β±0.23% (101 runs sampled)
π @msgpack/msgpack x 4,096 ops/sec Β±0.25% (100 runs sampled)
π msgpack5 x 920 ops/sec Β±0.34% (99 runs sampled)
π msgpack-lite x 1,223 ops/sec Β±0.10% (100 runs sampled)
π messagepack x 194 ops/sec Β±1.93% (73 runs sampled)
Fastest is π json-pack MsgPackDecoderFast
-------------------------------------------------------------------------- Large object, 3741 bytes
π JSON.parse() x 91,582 ops/sec Β±0.30% (100 runs sampled)
π sjson.parse() x 84,411 ops/sec Β±0.16% (99 runs sampled)
π json-pack CborDecoderBase x 94,618 ops/sec Β±0.27% (97 runs sampled)
π cbor-x x 108,102 ops/sec Β±0.37% (101 runs sampled)
π cbor x 4,845 ops/sec Β±0.79% (95 runs sampled)
π json-pack MsgPackDecoderFast x 102,544 ops/sec Β±0.39% (99 runs sampled)
π msgpackr x 111,668 ops/sec Β±0.16% (101 runs sampled)
π @msgpack/msgpack x 56,952 ops/sec Β±0.51% (97 runs sampled)
π msgpack5 x 17,420 ops/sec Β±0.60% (101 runs sampled)
π msgpack-lite x 20,536 ops/sec Β±0.23% (98 runs sampled)
π messagepack x 3,247 ops/sec Β±2.30% (87 runs sampled)
Fastest is π msgpackr
------------------------------------------------------------------------- Typical object, 993 bytes
π JSON.parse() x 304,670 ops/sec Β±0.98% (97 runs sampled)
π sjson.parse() x 283,259 ops/sec Β±0.20% (98 runs sampled)
π json-pack CborDecoderBase x 298,666 ops/sec Β±0.19% (100 runs sampled)
π cbor-x x 322,995 ops/sec Β±0.71% (97 runs sampled)
π cbor x 14,391 ops/sec Β±0.88% (95 runs sampled)
π json-pack MsgPackDecoderFast x 321,984 ops/sec Β±0.23% (100 runs sampled)
π msgpackr x 328,671 ops/sec Β±0.31% (99 runs sampled)
π @msgpack/msgpack x 198,604 ops/sec Β±0.85% (96 runs sampled)
π msgpack5 x 51,549 ops/sec Β±0.32% (99 runs sampled)
π msgpack-lite x 67,171 ops/sec Β±0.19% (99 runs sampled)
π messagepack x 9,464 ops/sec Β±1.95% (92 runs sampled)
Fastest is π msgpackr
---------------------------------------------------------------------------- Small object, 44 bytes
π JSON.parse() x 2,654,389 ops/sec Β±0.28% (98 runs sampled)
π sjson.parse() x 2,325,941 ops/sec Β±0.21% (98 runs sampled)
π json-pack CborDecoderBase x 3,357,402 ops/sec Β±0.31% (99 runs sampled)
π cbor-x x 4,133,737 ops/sec Β±0.29% (101 runs sampled)
π cbor x 112,776 ops/sec Β±5.79% (88 runs sampled)
π json-pack MsgPackDecoderFast x 3,359,127 ops/sec Β±0.56% (98 runs sampled)
π msgpackr x 3,436,592 ops/sec Β±0.35% (97 runs sampled)
π @msgpack/msgpack x 2,288,251 ops/sec Β±0.52% (94 runs sampled)
π msgpack5 x 377,061 ops/sec Β±0.67% (96 runs sampled)
π msgpack-lite x 872,569 ops/sec Β±0.31% (100 runs sampled)
π messagepack x 116,422 ops/sec Β±1.84% (86 runs sampled)
Fastest is π cbor-x
------------------------------------------------------------------ Object with many keys, 969 bytes
π JSON.parse() x 270,312 ops/sec Β±0.57% (98 runs sampled)
π sjson.parse() x 242,328 ops/sec Β±3.10% (97 runs sampled)
π json-pack CborDecoderBase x 81,403 ops/sec Β±0.42% (96 runs sampled)
π cbor-x x 93,131 ops/sec Β±0.48% (99 runs sampled)
π cbor x 8,760 ops/sec Β±0.93% (95 runs sampled)
π json-pack MsgPackDecoderFast x 84,014 ops/sec Β±0.31% (96 runs sampled)
π msgpackr x 91,477 ops/sec Β±0.77% (90 runs sampled)
π @msgpack/msgpack x 73,089 ops/sec Β±0.56% (89 runs sampled)
π msgpack5 x 23,468 ops/sec Β±0.72% (97 runs sampled)
π msgpack-lite x 34,630 ops/sec Β±0.48% (100 runs sampled)
π messagepack x 6,161 ops/sec Β±1.77% (86 runs sampled)
Fastest is π JSON.parse()
------------------------------------------------------------------------- String ladder, 3398 bytes
π JSON.parse() x 287,387 ops/sec Β±0.36% (99 runs sampled)
π sjson.parse() x 192,836 ops/sec Β±0.40% (95 runs sampled)
π json-pack CborDecoderBase x 177,787 ops/sec Β±0.48% (98 runs sampled)
π cbor-x x 320,303 ops/sec Β±0.51% (94 runs sampled)
π cbor x 15,416 ops/sec Β±0.61% (94 runs sampled)
π json-pack MsgPackDecoderFast x 179,625 ops/sec Β±0.59% (100 runs sampled)
π msgpackr x 375,452 ops/sec Β±0.69% (94 runs sampled)
π @msgpack/msgpack x 36,544 ops/sec Β±0.75% (84 runs sampled)
π msgpack5 x 54,428 ops/sec Β±0.46% (98 runs sampled)
π msgpack-lite x 25,309 ops/sec Β±0.81% (75 runs sampled)
π messagepack x 10,117 ops/sec Β±3.99% (82 runs sampled)
Fastest is π msgpackr
-------------------------------------------------------------------------- Long strings, 7011 bytes
π JSON.parse() x 117,335 ops/sec Β±3.32% (89 runs sampled)
π sjson.parse() x 103,275 ops/sec Β±0.64% (94 runs sampled)
π json-pack CborDecoderBase x 74,140 ops/sec Β±7.50% (81 runs sampled)
π cbor-x x 92,753 ops/sec Β±0.78% (96 runs sampled)
π cbor x 24,292 ops/sec Β±27.70% (75 runs sampled)
π json-pack MsgPackDecoderFast x 88,124 ops/sec Β±1.65% (90 runs sampled)
π msgpackr x 94,352 ops/sec Β±0.91% (94 runs sampled)
π @msgpack/msgpack x 33,256 ops/sec Β±30.68% (71 runs sampled)
π msgpack5 x 68,367 ops/sec Β±0.70% (95 runs sampled)
π msgpack-lite x 14,764 ops/sec Β±2.04% (63 runs sampled)
π messagepack x 17,522 ops/sec Β±28.57% (66 runs sampled)
Fastest is π JSON.parse()
-------------------------------------------------------------------------- Short strings, 170 bytes
π JSON.parse() x 1,077,084 ops/sec Β±6.88% (77 runs sampled)
π sjson.parse() x 837,130 ops/sec Β±2.70% (80 runs sampled)
π json-pack CborDecoderBase x 698,901 ops/sec Β±4.69% (88 runs sampled)
π cbor-x x 1,182,303 ops/sec Β±0.39% (94 runs sampled)
π cbor x 26,810 ops/sec Β±14.70% (73 runs sampled)
π json-pack MsgPackDecoderFast x 742,562 ops/sec Β±5.06% (88 runs sampled)
π msgpackr x 1,041,143 ops/sec Β±2.66% (85 runs sampled)
π @msgpack/msgpack x 440,652 ops/sec Β±1.38% (92 runs sampled)
π msgpack5 x 133,387 ops/sec Β±1.14% (96 runs sampled)
π msgpack-lite x 206,844 ops/sec Β±0.63% (97 runs sampled)
π messagepack x 23,818 ops/sec Β±2.13% (94 runs sampled)
Fastest is π cbor-x,π JSON.parse()
-------------------------------------------------------------------------------- Numbers, 136 bytes
π JSON.parse() x 1,747,460 ops/sec Β±0.61% (95 runs sampled)
π sjson.parse() x 1,553,635 ops/sec Β±1.04% (93 runs sampled)
π json-pack CborDecoderBase x 2,289,002 ops/sec Β±0.93% (87 runs sampled)
π cbor-x x 3,775,727 ops/sec Β±2.86% (82 runs sampled)
π cbor x 77,650 ops/sec Β±4.32% (83 runs sampled)
π json-pack MsgPackDecoderFast x 2,287,682 ops/sec Β±1.54% (80 runs sampled)
π msgpackr x 3,391,489 ops/sec Β±0.59% (80 runs sampled)
π @msgpack/msgpack x 2,297,255 ops/sec Β±1.54% (78 runs sampled)
π msgpack5 x 112,373 ops/sec Β±1.19% (91 runs sampled)
π msgpack-lite x 1,378,387 ops/sec Β±0.84% (95 runs sampled)
π messagepack x 1,174,740 ops/sec Β±0.97% (89 runs sampled)
Fastest is π cbor-x
--------------------------------------------------------------------------------- Tokens, 308 bytes
π JSON.parse() x 1,303,300 ops/sec Β±2.26% (92 runs sampled)
π sjson.parse() x 1,091,921 ops/sec Β±2.85% (86 runs sampled)
π json-pack CborDecoderBase x 1,203,319 ops/sec Β±2.12% (90 runs sampled)
π cbor-x x 1,787,591 ops/sec Β±2.94% (74 runs sampled)
π cbor x 45,127 ops/sec Β±24.11% (64 runs sampled)
π json-pack MsgPackDecoderFast x 1,283,322 ops/sec Β±1.93% (94 runs sampled)
π msgpackr x 1,890,533 ops/sec Β±2.66% (90 runs sampled)
π @msgpack/msgpack x 1,364,025 ops/sec Β±3.78% (67 runs sampled)
π msgpack5 x 117,205 ops/sec Β±2.72% (90 runs sampled)
π msgpack-lite x 1,316,133 ops/sec Β±0.74% (99 runs sampled)
π messagepack x 733,566 ops/sec Β±1.55% (87 runs sampled)
Fastest is π msgpackr
Encoder comparison:
npx ts-node benchmarks/json-pack/bench.encoders.ts
=============================================================================== Benchmark: Encoding
Warmup: 1000x , Node.js: v20.2.0 , Arch: arm64 , CPU: Apple M1 Max
---------------------------------------------------------------------------- Small object, 44 bytes
π CborEncoderFast x 6,319,117 ops/sec Β±0.11% (101 runs sampled)
π CborEncoder x 6,001,443 ops/sec Β±0.15% (101 runs sampled)
π MsgPackEncoderFast x 6,047,466 ops/sec Β±0.20% (99 runs sampled)
π MsgPackEncoder x 5,493,093 ops/sec Β±0.10% (101 runs sampled)
π JsonEncoder x 6,018,890 ops/sec Β±0.11% (97 runs sampled)
π UbjsonEncoder x 6,545,118 ops/sec Β±0.10% (97 runs sampled)
π IonEncoderFast x 1,032,434 ops/sec Β±0.14% (99 runs sampled)
π Buffer.from(JSON.stringify()) x 2,300,069 ops/sec Β±0.15% (100 runs sampled)
Fastest is π UbjsonEncoder
------------------------------------------------------------------------- Typical object, 993 bytes
π CborEncoderFast x 460,125 ops/sec Β±0.14% (98 runs sampled)
π CborEncoder x 439,506 ops/sec Β±0.18% (98 runs sampled)
π MsgPackEncoderFast x 458,530 ops/sec Β±0.15% (99 runs sampled)
π MsgPackEncoder x 449,540 ops/sec Β±0.16% (100 runs sampled)
π JsonEncoder x 303,410 ops/sec Β±0.12% (101 runs sampled)
π UbjsonEncoder x 479,450 ops/sec Β±0.13% (99 runs sampled)
π IonEncoderFast x 68,000 ops/sec Β±0.11% (102 runs sampled)
π Buffer.from(JSON.stringify()) x 207,747 ops/sec Β±0.11% (98 runs sampled)
Fastest is π UbjsonEncoder
-------------------------------------------------------------------------- Large object, 3741 bytes
π CborEncoderFast x 133,608 ops/sec Β±0.15% (100 runs sampled)
π CborEncoder x 128,019 ops/sec Β±0.13% (97 runs sampled)
π MsgPackEncoderFast x 133,863 ops/sec Β±0.14% (99 runs sampled)
π MsgPackEncoder x 131,521 ops/sec Β±0.18% (99 runs sampled)
π JsonEncoder x 93,018 ops/sec Β±0.13% (98 runs sampled)
π UbjsonEncoder x 140,969 ops/sec Β±0.15% (101 runs sampled)
π IonEncoderFast x 11,523 ops/sec Β±0.15% (101 runs sampled)
π Buffer.from(JSON.stringify()) x 63,389 ops/sec Β±0.13% (101 runs sampled)
Fastest is π UbjsonEncoder
-------------------------------------------------------------------- Very large object, 45750 bytes
π CborEncoderFast x 5,790 ops/sec Β±0.15% (100 runs sampled)
π CborEncoder x 5,579 ops/sec Β±0.14% (100 runs sampled)
π MsgPackEncoderFast x 6,005 ops/sec Β±0.13% (100 runs sampled)
π MsgPackEncoder x 5,670 ops/sec Β±0.18% (99 runs sampled)
π JsonEncoder x 6,351 ops/sec Β±0.16% (101 runs sampled)
π UbjsonEncoder x 6,248 ops/sec Β±0.18% (99 runs sampled)
π IonEncoderFast x 1,868 ops/sec Β±0.21% (98 runs sampled)
π Buffer.from(JSON.stringify()) x 7,240 ops/sec Β±0.19% (99 runs sampled)
Fastest is π Buffer.from(JSON.stringify())
------------------------------------------------------------------ Object with many keys, 969 bytes
π CborEncoderFast x 283,371 ops/sec Β±0.18% (99 runs sampled)
π CborEncoder x 268,056 ops/sec Β±0.17% (96 runs sampled)
π MsgPackEncoderFast x 285,224 ops/sec Β±0.17% (96 runs sampled)
π MsgPackEncoder x 272,416 ops/sec Β±0.21% (98 runs sampled)
π JsonEncoder x 234,921 ops/sec Β±0.21% (98 runs sampled)
π UbjsonEncoder x 292,228 ops/sec Β±0.19% (95 runs sampled)
π IonEncoderFast x 63,456 ops/sec Β±0.14% (98 runs sampled)
π Buffer.from(JSON.stringify()) x 175,341 ops/sec Β±0.86% (93 runs sampled)
Fastest is π UbjsonEncoder
------------------------------------------------------------------------- String ladder, 3398 bytes
π CborEncoderFast x 280,167 ops/sec Β±0.20% (100 runs sampled)
π CborEncoder x 283,404 ops/sec Β±0.20% (97 runs sampled)
π MsgPackEncoderFast x 272,800 ops/sec Β±0.18% (99 runs sampled)
π MsgPackEncoder x 283,433 ops/sec Β±0.23% (98 runs sampled)
π JsonEncoder x 147,390 ops/sec Β±0.16% (98 runs sampled)
π UbjsonEncoder x 290,624 ops/sec Β±0.21% (98 runs sampled)
π IonEncoderFast x 25,452 ops/sec Β±0.17% (101 runs sampled)
π Buffer.from(JSON.stringify()) x 145,352 ops/sec Β±0.23% (99 runs sampled)
Fastest is π UbjsonEncoder
-------------------------------------------------------------------------- Long strings, 7011 bytes
π CborEncoderFast x 394,386 ops/sec Β±0.53% (95 runs sampled)
π CborEncoder x 394,442 ops/sec Β±0.49% (94 runs sampled)
π MsgPackEncoderFast x 386,894 ops/sec Β±0.54% (95 runs sampled)
π MsgPackEncoder x 394,019 ops/sec Β±0.50% (95 runs sampled)
π JsonEncoder x 50,781 ops/sec Β±0.13% (97 runs sampled)
π UbjsonEncoder x 396,184 ops/sec Β±0.57% (95 runs sampled)
π IonEncoderFast x 11,799 ops/sec Β±0.22% (99 runs sampled)
π Buffer.from(JSON.stringify()) x 28,742 ops/sec Β±0.11% (102 runs sampled)
Fastest is π UbjsonEncoder,π CborEncoder,π CborEncoderFast,π MsgPackEncoder
-------------------------------------------------------------------------- Short strings, 170 bytes
π CborEncoderFast x 1,816,742 ops/sec Β±0.16% (100 runs sampled)
π CborEncoder x 1,831,503 ops/sec Β±0.22% (97 runs sampled)
π MsgPackEncoderFast x 1,641,743 ops/sec Β±0.17% (101 runs sampled)
π MsgPackEncoder x 1,694,803 ops/sec Β±0.17% (97 runs sampled)
π JsonEncoder x 1,595,041 ops/sec Β±0.12% (99 runs sampled)
π UbjsonEncoder x 1,779,112 ops/sec Β±0.24% (98 runs sampled)
π IonEncoderFast x 422,031 ops/sec Β±0.10% (101 runs sampled)
π Buffer.from(JSON.stringify()) x 1,001,976 ops/sec Β±0.24% (98 runs sampled)
Fastest is π CborEncoder
-------------------------------------------------------------------------------- Numbers, 136 bytes
π CborEncoderFast x 2,822,683 ops/sec Β±0.14% (99 runs sampled)
π CborEncoder x 3,111,311 ops/sec Β±0.20% (97 runs sampled)
π MsgPackEncoderFast x 2,918,971 ops/sec Β±0.14% (100 runs sampled)
π MsgPackEncoder x 2,862,193 ops/sec Β±0.13% (100 runs sampled)
π JsonEncoder x 1,706,584 ops/sec Β±0.18% (96 runs sampled)
π UbjsonEncoder x 3,238,810 ops/sec Β±0.15% (97 runs sampled)
π IonEncoderFast x 545,885 ops/sec Β±0.16% (98 runs sampled)
π Buffer.from(JSON.stringify()) x 1,216,907 ops/sec Β±0.20% (98 runs sampled)
Fastest is π UbjsonEncoder
--------------------------------------------------------------------------------- Tokens, 308 bytes
π CborEncoderFast x 1,360,976 ops/sec Β±0.20% (96 runs sampled)
π CborEncoder x 1,367,625 ops/sec Β±0.16% (101 runs sampled)
π MsgPackEncoderFast x 1,753,202 ops/sec Β±0.19% (99 runs sampled)
π MsgPackEncoder x 1,733,298 ops/sec Β±0.16% (100 runs sampled)
π JsonEncoder x 1,411,382 ops/sec Β±0.27% (98 runs sampled)
π UbjsonEncoder x 1,734,304 ops/sec Β±0.17% (101 runs sampled)
π IonEncoderFast x 369,161 ops/sec Β±0.21% (97 runs sampled)
π Buffer.from(JSON.stringify()) x 1,092,623 ops/sec Β±0.15% (101 runs sampled)
Fastest is π MsgPackEncoderFast
node benchmarks/json-pack/bench.shallow-read.js
=============================================================================== Benchmark: Encoding
Warmup: 10000x , Node.js: v16.14.2 , Arch: arm64 , CPU: Apple M1
------------------------------------------------------------------------- Typical object, 993 bytes
π JSON.parse() x 314,451 ops/sec Β±0.24% (94 runs sampled)
π msgpackr x 332,628 ops/sec Β±0.09% (99 runs sampled)
π cbor-x x 326,509 ops/sec Β±0.05% (101 runs sampled)
π MsgPackDecoder x 368,088 ops/sec Β±0.15% (100 runs sampled)
π CborDecoder x 327,286 ops/sec Β±0.15% (101 runs sampled)
π MsgPackDecoder.{findKey,findIndex}() x 1,815,090 ops/sec Β±0.07% (99 runs sampled)
π MsgPackDecoder.find() x 1,797,098 ops/sec Β±0.15% (98 runs sampled)
π genShallowReader()(MsgPackDecoder) x 2,085,260 ops/sec Β±0.19% (99 runs sampled)
Fastest is π genShallowReader()(MsgPackDecoder)