We have a v.large Dictionary<long,uint> (several million entries) as part of a high performance C# application. When the application closes we serialise the dictionary to disk using BinaryFormatter and MemoryStream.ToArray(). The serialisation returns in about 30 seconds and produces a file about 200MB in size. When we then try to deserialise the dictionary using the following code:
BinaryFormatter bin = new BinaryFormatter();
Stream stream = File.Open("filePathName", FileMode.Open);
Dictionary<long, uint> allPreviousResults =
(Dictionary<long, uint>)bin.Deserialize(stream);
stream.Close();
It takes about 15 minutes to return. We have tried alternatives and the slow part is definitely bin.Derserialize(stream), i.e. the bytes are read from the hard drive (high performance SSD) in under 1 second.
Can someone please point out what we are doing wrong as we want the load time on the same order as the save time.
Regards, Marc