In my game I used the attribute [Serializable]
on relevant classes to serialise my campaign (a collection of maps and levels) into a single file but now the campaign is nearing 20MB in size and it's becoming too slow for serialising/deserialising.
It currently takes about 11 seconds to deserialise the campaign into memory from disk.
I know about protobuf-net but I want to try the ISerializable
approach for now. Would implementing the ISerializable
interface on a class interfere with the deserialisation of a previous version of that class which only used [Serializable]
and [NonSerialized]
attributes to serialise?
I imagine I could create an ISerializable
copy of each relevant class and copy data from one to another but that sounds like a recipe for disaster.
Is it possible to tell the BinaryFormatter
to ignore any ISerializable
attributes and only deserialise using the [Serializable]
and [NonSerialized]
attributes?
Update 1: I use a custom binder to fix up type and assembly name differences but this made no noticable difference when not in use.
Update 2:
SSD embedded content deserialisation takes ~12.2s,
SSD disk file deserialisation takes ~11.4s,
MemoryStream
serialisation takes ~3.4s and
MemoryStream
deserialisation takes ~11.2s.
I feel silly but I forgot to mention this is all done on a seperate thread. I'll increase it's priority and see if that changes anything.
Update 3: loading thread priority set to Highest
trimmed off less than a second.
Thank you for your time.