-Fixed performance issue serializing XML document with a large number of nodes

This commit is contained in:
James Newton-King
2014-05-09 14:47:10 +12:00
parent cf7a83e91c
commit 57bd1f7daf
12 changed files with 31878 additions and 19 deletions
@@ -23,6 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
using System.Xml;
#if !(NET20 || NET35 || NETFX_CORE || PORTABLE)
using System;
using System.Collections;
@@ -180,6 +181,32 @@ namespace Newtonsoft.Json.Tests
SerializeSize(image);
}
#if !(PORTABLE40)
[Test]
public void ConvertXmlNode()
{
XmlDocument doc = new XmlDocument();
using (FileStream file = System.IO.File.OpenRead("large_sample.xml"))
{
doc.Load(file);
}
JsonConvert.SerializeXmlNode(doc);
}
[Test]
public void ConvertXNode()
{
XDocument doc;
using (FileStream file = System.IO.File.OpenRead("large_sample.xml"))
{
doc = XDocument.Load(file);
}
JsonConvert.SerializeXNode(doc);
}
#endif
private T TimeOperation<T>(Func<T> operation, string name)
{
// warm up