Rule of thumb: size of boost archive in relation to original serialized object?

…衆ロ難τιáo~ 提交于 2020-01-17 13:15:30

问题


For reasons that I will gloss over, I need to set aside space of a fixed size, and then use boost serialization to store an object there. The choice of archive format is arbitrary, and portability is not a concern.

The class is fairly complex (members include fundamental types, arrays, pointers, and child classes) and guaranteed to grow over time.

Does anyone have worthwhile sizing guestimates they trust? Space is important, but it's not at a premium. I'm looking for relatively simple answers like "2*(sizeof X) for binary" or "4 * number of members + 3*sizeof(X) if you like text archives".

Thanks


回答1:


No responses, so here's what experimentation showed.

From our application, one class had ~190 members, sizeof(A) = 12704. That's a little shy of actual total size due to pointers.

Size of binary_oarchive was 13981 and text_oarchive was 21237. This was for default traits, and an archive with a half-dozen derived types registered too.

So, I'm going to use 2*sizeof(A) as an upper bound for a text archive, and maybe 1.5* for a binary.



来源:https://stackoverflow.com/questions/3133621/rule-of-thumb-size-of-boost-archive-in-relation-to-original-serialized-object

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