开发者

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

开发者 https://www.devze.com 2023-01-04 19:52 出处:网络
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 n

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 com开发者_C百科plex (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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消