0

I want to serialize a huge amount of data to just able to save and load during running and startup(I do not need any version system, or compatibility during all platforms). So the performance of these jobs are critical for me. After some searches I understood that I must use something like boost-serialize which does not need any precompilation job. After measuring the performance of my code, I got that most parts of my program in doing serialization spend on strcmp function which is used for type identification.

I have found that we are able to implement our type identification using boost as shown here. But I have two questions about that:

  1. As I found all type identification implementation needs to override get_key function which it returns a const char*, so it seems that all type identification must be based on const char* and so string comparison still exists which does not seem promising.
  2. I prefer to use for example a unsigned int index for each class to identify them during run-time, is there any standard way to do this? Notice that the id assigned to each class must be same in all runs of the program.
motam
  • 677
  • 1
  • 6
  • 24
  • You can stop serializing pointers if you don't need the runtime polymorphism. I remember this seemed the case from your previou questioins – sehe Feb 18 '16 at 21:44
  • No, unfortunately I can't disable polymorphism. This feature is an essential part of my work. – motam Feb 19 '16 at 07:39
  • I meant for the serialising only – sehe Feb 19 '16 at 08:08
  • In my data structure I have many pointer to abstract classes which must be serialized. But your comment may make sense that I do not serialize a pointer but just serialize data inside it and in deserialization first allocate the pointer then copy data to them. I must check this solution, I will tell you the results I get. – motam Feb 19 '16 at 08:34
  • I tried to implement your suggestion to avoid serializing pointer, it would be possible, for example I can write a virtual method for abstract class and serialize all children classes using overriding this method. But there is a problem assume that I had used extensively of stl containers (`map`) for avoiding pointer serialization I have to implement all serialization of even stl containers manually. So I think still that changing type-identification procedure is a more feasible solution. – motam Feb 20 '16 at 06:06
  • @sehe Please look at my last comment. – motam Feb 22 '16 at 05:44

0 Answers0