经验法则:与原始序列化对象相关的 boost 存档大小? [英] Rule of thumb: size of boost archive in relation to original serialized object?

查看:23
本文介绍了经验法则:与原始序列化对象相关的 boost 存档大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于我将掩盖的原因,我需要留出固定大小的空间,然后使用 boost 序列化在那里存储对象.存档格式的选择是任意的,不考虑可移植性.

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.

有没有人有值得信赖的估计尺寸?空间很重要,但并不重要.我正在寻找相对简单的答案,例如2*(sizeof X) for binary"或4 * number of members + 3*sizeof(X) if you like text archives".

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".

谢谢

推荐答案

没有回应,所以这是实验结果.

No responses, so here's what experimentation showed.

在我们的应用程序中,一个类有大约 190 个成员,sizeof(A) = 12704.由于指针的原因,这与实际总大小略有不同.

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

binary_oarchive 的大小为 13981,text_oarchive 的大小为 21237.这是默认特征,并且还注册了六个派生类型的存档.

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.

因此,我将使用 2*sizeof(A) 作为文本存档的上限,对于二进制文件可能使用 1.5*.

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

这篇关于经验法则:与原始序列化对象相关的 boost 存档大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆