开发者

One large Stream, or several smaller Streams?

I am using XmlText开发者_如何学GoWriter to create a large (huge) xml string but I wonder if I should create more than one writer and create smaller xml instead of just a big one. In regards to memory and performance what is the impact by having huge xml streams versus smaller streams?

StringWriter sw = new StringWriter();
XmlTextWriter myXml = new XmlTextWriter(sw);


It's better to create smaller xml instead of big one. When you have huge xml streams parsing through the streams or using that object to save the xml can be slower as compared to the smaller streams.


Many small xml is almost always better than a single big xml.

As far as Framework 4.0, StringWriter & XmlTextWriter are single threaded. By splitting the huge xml to smaller xmls you can dramatically improve performance by assigning each xml task to a different thread.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜