提高MPI和序列化对象的大小
Boost MPI and size of serialized object
在我的大学里,我必须测量使用MPI发送的c++ STL类型序列化的开销。
测量时间很容易,但如果我想测量例如发送1000个字符的vector
和1000个字符的数组需要多少字节,我就会遇到问题。看看Boost.MPI
文档:http://www.boost.org/doc/libs/1_55_0/doc/html/mpi/tutorial.html#mpi.user_data_types我可以看到它使用Boost.Serialization
进行序列化:http://www.boost.org/doc/libs/1_55_0/libs/serialization/doc/
Boost.Serialization
在序列化期间使用存档,但我看不出是否有一种方法可以从存档中提取它所需的字节量?我不是很熟悉boost文档,所以我可能会错过一些东西。
开始:
#include <iostream>
#include <sstream>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/serialization/vector.hpp>
int main()
{
std::ostringstream oss;
boost::archive::binary_oarchive oa(oss);
std::vector<char> v(1000);
// stream
oa << v;
std::cout << "The number of bytes taken for the vector in an archive is " << oss.str().size() << "n";
}
在我的系统上它打印:
The number of bytes taken for the vector in an archive is 1048
查看Live On Coliru
有可能MPI的packed_oarchive
做了额外的压缩。我在文档中没有发现这个
相关文章:
- 自定义对象的dlib序列化在gcc中失败
- 提升反序列化对象具有 nan 或 -nan 值
- 在 cpp 中的平面缓冲区中序列化对象
- 将 boost 序列化对象的 asio::streambuf 表示转换为 Beast 的 DynamicBody req.body()
- POCO C++对象到 JSON 字符串序列化
- C++ 提升 - 包含类层次结构对象的类的序列化
- 从一个文件中读取多个序列化对象
- 在对象序列化期间添加额外参数是否有更好的方法?
- C++中的对象序列化,用于存储 OpenCV 的 SVM 对象 [OpenCV 3.1.0]
- C++ <-> AS3 对象序列化
- 为什么我们需要C++的对象序列化
- C++的几个对象序列化
- 脚本到二进制转换和对象序列化
- C++对象序列化
- C#中的MFC对象序列化
- 对c++对象序列化技术的建议
- 从特征(SparseLU对象)序列化分解矩阵
- 增强多对象序列化
- C++Boost对象序列化-定期保存以保护数据
- 提升 MPL 以生成用于对象序列化的代码