Performance: XmlSerializer vs XmlReader vs XmlDocument vs XDocument

I am working on a small web project and want to read / write to an XML file. Performance is my first priority.

I came to this excellent post comparing the mentioned approaches except XmlSerializer .

I prefer XmlSerializer as it makes the code much cleaner. But I do not know about its performance. What type of XmlSerializer used internally for writing to XML files?

+6
linq-to-xml xmlreader xmldocument xmlserializer
source share
1 answer

Regarding the performance of the XmlSerializer, see http://msdn.microsoft.com/en-us/library/182eeyhh.aspx , which says:

XmlSerializer creates C # files and compiles them into DLL files in this serialization. In the .NET Framework 2.0, the XML Serializer Generator Tool (Sgen.exe) is designed to generate this serialization in advance to assemble assemblies with your application and improve startup performance.

This way you can increase the performance of XmlSerializer using the sgen tool http://msdn.microsoft.com/en-us/library/bk3w6240.aspx , so you can avoid the performance that you get when the new XmlSerializer () creates and compiles C # files.

+4
source share

All Articles