Hi...
I've been trying to improve the performance of our xml handling, so I've
been doing some timing tests lately and ran across something I thought odd -
XPathDocument seems slightly slower than XmlDocument. I've run the tests
several times and have tried to eliminate extraneous variables like disk
access but every time, XPathDocument comes up slower by a few percent.
I'd expected it to be faster since it's a read-only representation. Am I
doing something wrong?
start = Timers.QueryPer formanceCounter ();
for (int idx = 0; idx < 50000; idx++)
{
StringReader sr = new StringReader(xm ldoc);
doc = new XmlDocument();
doc.Load(sr);
}
start = Timers.SinceMil liSeconds(start );
Console.WriteLi ne(start);
start = Timers.QueryPer formanceCounter ();
for (int idx = 0; idx < 50000; idx++)
{
StringReader sr = new StringReader(xm ldoc);
pDoc = new XPathDocument(s r);
}
start = Timers.SinceMil liSeconds(start );
Console.WriteLi ne(start);
In other tests, XPathDocument seemed to improve
XslCompiledTran sform.Transform performance very slightly, but not enough to
justify the switch given that the loading seemed more expensive...
Thanks
Mark
I've been trying to improve the performance of our xml handling, so I've
been doing some timing tests lately and ran across something I thought odd -
XPathDocument seems slightly slower than XmlDocument. I've run the tests
several times and have tried to eliminate extraneous variables like disk
access but every time, XPathDocument comes up slower by a few percent.
I'd expected it to be faster since it's a read-only representation. Am I
doing something wrong?
start = Timers.QueryPer formanceCounter ();
for (int idx = 0; idx < 50000; idx++)
{
StringReader sr = new StringReader(xm ldoc);
doc = new XmlDocument();
doc.Load(sr);
}
start = Timers.SinceMil liSeconds(start );
Console.WriteLi ne(start);
start = Timers.QueryPer formanceCounter ();
for (int idx = 0; idx < 50000; idx++)
{
StringReader sr = new StringReader(xm ldoc);
pDoc = new XPathDocument(s r);
}
start = Timers.SinceMil liSeconds(start );
Console.WriteLi ne(start);
In other tests, XPathDocument seemed to improve
XslCompiledTran sform.Transform performance very slightly, but not enough to
justify the switch given that the loading seemed more expensive...
Thanks
Mark
Comment