Using syntactic serialization, I am trying to find the best settings for fast binary serialization of large objects. My tests show that for a structure labeled with bitwise serializable, I get better performance on arrays (and vectors), and not on individual objects.
For example, let's say I have this structure consisting only of POD types
struct BigStruct { double m1; long long m2; float m3;
Then serialize one 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();
takes about 7 times longer than serializing an 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();
Am I missing something? Is this an oversight in forcing serialization?
BTW I am using boost v1.53.
source share