Boost Serialization of vector<char>

帅比萌擦擦* 提交于 2019-12-02 10:02:03

问题


Does serializing a binary sequence stored in vector cost much? For example if I am using binary archive. Will the boost::serialization library put characters to differentiate char elements of vector and make the output larger?


回答1:


Measure it!

The sort answers:

  • No it doesn't cost much. Profile it (and see whether it fits your application)
  • No, vector elements will not be differentiated for vectors of POD types.
    (Things change when you serialize vectors containing pointers to polymorphic classes. This is obvious, since it couldn't be done more efficiently unless you have extra knowledge about the particular dataset)

The storage cost:

Longer answers:

  • Boost C++ Serialization overhead (comparative storage efficiency of different archives, with and without compression)

  • Boost Serialization Binary Archive giving incorrect output (on why some types take more than the potential bare minimum, e.g. on 64bit systems)

  • Tune things

    • boost::archive::no_header

The runtime cost:

  • how to do performance test using the boost library for a custom library

  • Tune things

    • boost::archive::no_codecvt


来源:https://stackoverflow.com/questions/27950322/boost-serialization-of-vectorchar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!