Thursday, 15 April 2010

c++ - boost binary serialization - why does bitwise copying only seem to work on collections? -



c++ - boost binary serialization - why does bitwise copying only seem to work on collections? -

using boost serialization, i'm trying find best settings fast binary serialization of big objects. tests indicate that, construction tagged bitwise serializable, improve performance on arrays (and vectors), not on individual objects.

for instance, have construction made of pod types

struct bigstruct { double m1; long long m2; float m3; // ... bool m499; short m500; }; namespace boost { namespace serialization { template <class archive> void serialize(archive& ioarchive, bigstruct& iostruct, const unsigned int iversion) { ioarchive & iostruct.m1; ioarchive & iostruct.m2; ioarchive & iostruct.m3; // ... ioarchive & iostruct.m499; ioarchive & iostruct.m500; } } } #include <boost/serialization/is_bitwise_serializable.hpp> boost_is_bitwise_serializable(bigstruct);

then, serializing single object

{ std::ofstream outstream(tmpfolder + "/binaryserializationofbigstruct.txt", std::ios_base::binary); boost::archive::binary_oarchive binoutarchive(outstream, boost::archive::no_header); bigstruct bigstruct; std::clock_t c_start = std::clock(); binoutarchive << bigstruct; std::clock_t c_end = std::clock(); // ...compute elapsed time... }

takes 7 times longer serializing array of 1 object

{ std::ofstream outstream(tmpfolder + "/binaryserializationofbigstructarray.txt", std::ios_base::binary); boost::archive::binary_oarchive binoutarchive(outstream, boost::archive::no_header); bigstruct bigstructarray[1]; std::clock_t c_start = std::clock(); binoutarchive << bigstructarray; std::clock_t c_end = std::clock(); // ...compute elapsed time... }

am missing something? oversight in boost serialization?

btw i'm using boost v1.53.

c++ boost binary bit-manipulation boost-serialization

No comments:

Post a Comment