性能:XmlSerializer的VS的XmlReader VS XmlDocument的VS的XDocument [英] Performance: XmlSerializer vs XmlReader vs XmlDocument vs XDocument

查看:696
本文介绍了性能:XmlSerializer的VS的XmlReader VS XmlDocument的VS的XDocument的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个小的网络项目,并想读/写XML文件。性能是我的首要任务。

I'm working on a little web project and would like to read/write to an XML file. Performance is my first priority.

我来这个伟大的帖子比较上除了提到的方法的XmlSerializer

I've come to this great post on comparing the mentioned approaches except XmlSerializer.

我preFER 的XmlSerializer ,因为它使code干净多了。但我不知道它的性能。确实的XmlSerializer 用什么样的里面写XML文件?

I prefer XmlSerializer since it makes the code much cleaner. But I don't know about its performance. What kind does XmlSerializer use inside to write to XML files?

推荐答案

至于XmlSerializer的表现,看到的 http://msdn.microsoft.com/en-us/library/182eeyhh.aspx 它说:

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

XmlSerializer的创建C#文件和   编译成.dll文件到   执行此序列化。在.NET中   框架2.0,XML序列   生成器工具(Sgen.exe)设计   产生这些序列   预先装配到被部署   您的应用和提高   启动性能。

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

所以,你可以通过利用SGEN工具 HTTP提高XmlSerializer的性能: //msdn.microsoft.com/en-us/library/bk3w6240.aspx ,这样就能避免性能打你当新的XmlSerializer()创建和编译C#文件。

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

这篇关于性能:XmlSerializer的VS的XmlReader VS XmlDocument的VS的XDocument的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆