[Mono-dev] Creating fewer objects (Sys.Xml, Sys.Web)
Atsushi Eno
atsushi at ximian.com
Mon Mar 27 22:44:17 EST 2006
Actually I'm changing my mind to add cache string in XmlNameEntry
since it does not hit significant performance problem, while
depending on user code it could result in significant speed difference:
using System;
using System.Xml;
public class Test
{
public static void Main (string [] args)
{
XmlDocument doc = new XmlDocument ();
doc.Load (args [0]);
int loop = args.Length > 1 ? int.Parse (args [1]) : 100;
for (int i = 0; i < loop; i++)
PeekName (doc);
}
static void PeekName (XmlNode n)
{
if (n.Name == null)
return;
for (XmlNode c = n.FirstChild; c != null;
c = c.NextSibling)
PeekName (c);
if (n.Attributes == null)
return;
foreach (XmlAttribute a in n.Attributes)
PeekName (a);
}
}
(Run with such XML that has prefixed names, such as xsl stylesheet.)
Yours:
Total memory allocated: 6397 KB
real 0m9.935s
user 0m0.050s
sys 0m0.060s
My previous one:
Total memory allocated: 6394 KB
real 0m10.856s
user 0m0.070s
sys 0m0.030s
Mine now:
Total memory allocated: 6394 KB
real 0m10.045s
user 0m0.080s
sys 0m0.040s
Now it is checked in svn.
Atsushi Eno
Joshua Tauberer wrote:
> Atsushi Eno wrote:
>> Joshua Tauberer wrote:
>>> (My patch was cooler!)
>> Well, I have to say, it was beyond my expectation for me ;-)
>> On which part was your patch cooler? I don't think
>> specific-implementation-dependent code (internal AddQName) is good,
>> and more importantly, after your code future hackers would feel
>> reluctant to improve NameTable since your patch adds extra one
>> to care.
>
> Ok, ok, you win. :)
>
More information about the Mono-devel-list
mailing list