How expensive is binary deserialization?

  • Thread starter Thread starter Nick Z.
  • Start date Start date
N

Nick Z.

I need my program to start as fast as possible.

Will deserialization a few settings using binary deserialization affect
that? Or should I keep these settings in XML, will that be any better?

Thanks in advance,
Nick Z.
 
It would probably be determined by things like the amount of data that needs
to be converted, the complexity of the objects and sub-objects, and the
location where the configuration is stored or serialized data is stored.

For your particular situation it might be necessary to run some benchmark to
find the best performance.

Also, I have had mixed results with serializes. It is really cool, but if
your objects change, then that break any data that is already serialized.
 
Peter said:
It would probably be determined by things like the amount of data that needs
to be converted, the complexity of the objects and sub-objects, and the
location where the configuration is stored or serialized data is stored.

For your particular situation it might be necessary to run some benchmark to
find the best performance.

I am probably going to do that.
Also, I have had mixed results with serializes. It is really cool, but if
your objects change, then that break any data that is already serialized.

Yes I'm aware of that. I make sure I flush the data to disk when necessary.
 
</snip>

I think what he meant was that, if the number of properties of the object
you are serializing changes, deserialization doesn't work. This is a
problem I see in my development as a class definition evolves-- no big deal
in development, but it could be a problem in a production environment.

If anyone has any solutions for deserializing an object that has more
properties now than when it was serialized, please let me know (via ng).

Scott
 
Scott said:
</snip>

I think what he meant was that, if the number of properties of the object
you are serializing changes, deserialization doesn't work. This is a
problem I see in my development as a class definition evolves-- no big deal
in development, but it could be a problem in a production environment.

If anyone has any solutions for deserializing an object that has more
properties now than when it was serialized, please let me know (via ng).

Scott


You mean, if you have a class A.
Then serialize it to disk.
Then add an extra property to the definition of class A, making it class
B with the same name however.
And then you attempt to deserialize previously serialized class A from
disk into a class of type B with the same name it will fail.
In other words, if you try to deserialize a class that was serialized
with the old definition it wont work?

If thats the case I guess it shouldn't work...
Is there a way to check the type of an object (the data in the file)
before deserializing it? If yeah than you can simply deserialize into
the 'old' version of the class and then assign the values to the new
type of class and serialize again.
 
I never thought of that (deserializing and copying...). Though it does seem
like it would bloat the class library, since there would be two copies of
basically the same class (A and B). Personally, it seems like manual
serialization & deserialization would work better (using xmlformatter).
that way you could handle the case where the property in the class either
didn't exist, or there were more properties in the class than in the file.

Scott
 
The only problem with XML serialization is the fact that not all object
can be serialized.
 
Back
Top