C # - XML ​​deserialization vs binary deserialization - binary + deflation

I save a huge list of objects in a file and then deserialize them. The resulting xml file can be about 3 gigabytes in size.

I want deserialization to be super fast, so I tried all three approaches (xml, binary, compressed)

Obviously, deserializing a compressed file takes much longer than XML. But I have seen that binary deserialization also takes much longer against xml deserialization. This is normal? Shoudn't both xml and binary take about the same time to deserialize an object?

And what, in your opinion, would be the best option to use in terms of a good balance between file size and deserialization speed?

+3
source share
2 answers

In this performance comparison between all kinds of serialization methods that come with .NET (BinaryFormatter, XmlSerializer, DataContractSerializer, etc.) and protobuf, the protobuf serial converter seems to be much ahead of the serializers that come with .NET. The resulting size will also decrease. If the protobuf format is an option for you, I highly recommend you take a look at it. :-)

Another option: if deserialization is slow, use only the deserialization of the parts that you really need. Create an index file that tells you about the offsets of the objects you write to the data file so that you can quickly deserialize the objects you need with random access.

+5

, ISerializable, ( XML ). memoised , , . , , .

deflate .

+1

Source: https://habr.com/ru/post/1761194/


All Articles