[Mono-dev] [PATCH] - optimization for System.Xml.XmlNode::SelectSingleNode
tom hindle
tom_hindle at sil.org
Mon May 10 13:09:28 EDT 2010
Hi,
While performance profiling our code, with mono's nice profiling
tools :), I noticed System.Xml.XmlNode::SelectSingleNode was taking 23ms
a call while the sum of the methods it was calling took < 5ms.
SelectSingleNode is a very simple method however it contains a (dynamic)
down cast. I replaced the (Cstyle/prefix) cast with a 'as' cast and this
seem to reduce the method time by about 7ms.
// With 'Cstyle' cast
39672.303 1717 23.106
System.Xml.XmlNode::SelectSingleNode(string,XmlNamespaceManager)
Callers (with count) that contribute at least for 1%:
1717 100 % System.Xml.XmlNode::SelectSingleNode(string)
// With 'as' cast
29238.117 1880 15.552
System.Xml.XmlNode::SelectSingleNode(string,XmlNamespaceManager)
Callers (with count) that contribute at least for 1%:
1880 100 % System.Xml.XmlNode::SelectSingleNode(string)
I read that this is because 'as' cast generates IL instr 'isinst' while
'cstyle' cast generates 'castclass'.
The msdn documentation about XmlNode.SelectSingleNode doesn't state that
an InvalidCastException, can/could be thrown.
Is this a sensible thing to do? If so could someone review/commit my
patch as I believe it will make a fairly major difference for
applications that make much use of SelectSingleNode.
Thanks
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xmlnode-optimization.patch
Type: text/x-patch
Size: 505 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20100510/851110aa/attachment.bin
More information about the Mono-devel-list
mailing list