fastest c++ serialization?

后端 未结 11 2417
花落未央
花落未央 2021-02-18 18:08

Good morning all,

I\'m searching for a very fast binary serialization technique for c++. I only need to serialize data contained in objects (no pointers etc.). I\'d like

11条回答
  •  逝去的感伤
    2021-02-18 18:27

    To really answer this question, the reason why the C++ version is slow is that it calls the ostream.write too many times, which induce a huge amount of unnecessary state checks. You can create a simple buffer and use only one write and you will see the difference.

    If your disk/network is really fast enough to not become the bottleneck, flatbuffers capnproto are great options to handle this for you.

    Otherwise, protobuf, xxx-compact... whatever uses varint encoding can probably serialize these data to a quarter of the original size. HPS from the scientific computing community is also a great option for this kind of highly structured data and probably the fastest in speed and the smallest in message size in this case due to its encoding scheme.

提交回复
热议问题