Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any perfomormance differences between binary and XML serialization?

in terms of both parsing (serializing, deserializing) and sending packets over the network is there any good estimation of performance differences between binary and xml serialization?

like image 992
leora Avatar asked Dec 27 '08 02:12

leora


People also ask

When should we use binary serialization as compared to XML serialization?

Specific to . NET, If you have two applications that are using the same type system, then you can use binary serialization. On the other hand if you have applications that are in different platforms then it is recommended to use XML Serialization.

Why binary serialization is faster?

Binary serialization is more efficient because write raw data directly and the XML needs format, and parse the data to generate a valid XML structure, additionally depending of what sort of data have your objects the XML may have a lot of redundant data.

What is binary serialization?

Binary serialization allows modifying private members inside an object and therefore changing the state of it. Because of this, other serialization frameworks, like System. Text. Json, that operate on the public API surface are recommended.

Is XML a serialization format?

XML serialization serializes only the public fields and property values of an object into an XML stream. XML serialization does not include type information. For example, if you have a Book object that exists in the Library namespace, there is no guarantee that it is deserialized into an object of the same type.


1 Answers

Nope.

It depends highly on what sort of data is inside the XML document itself. If you have a lot of structured data, the overhead for XML will be large. For example, if your data looks like:

<person>
  <name>Dave</dave>
  <ssn>000-00-0000</ssn>
  <email1>xxxxxx/email1>
</person>
...

You'll have a lot more overhead than if you have an XML document that looks like:

<book name="bible">
 In the beginning God created the heavens and the earth. 
 Now the earth was formless and empty ... 
 And if any man shall take away from the words of the book of this prophecy, God shall take away his part out of the book of life, and out of the holy city, and from the things which are written in this book. He which testifieth these things saith, Surely I come quickly. Amen. Even so, come, Lord Jesus.
</book>

So it's not really a fair question. It depends highly on the data YOU intend to send, and how/if you're compressing it.

like image 190
Dave Markle Avatar answered Oct 20 '22 04:10

Dave Markle