Hi Jeff,
I must repeat myself for the third time: the DOMNamedNodeMapImpl
class (that uses the map with 197 buckets) is used only in the DTD
node, not in the elements. Would you mind double checking your
implementation of the XNode class?
Alberto
At 09.47 01/07/2005 -0700, Jeff Keasler wrote:
Alberto,
Thank you for getting back to me on this.
We write our DOM tree back out to disk after we parse it.
Below is the code we use to do that. As you can see, we loop over
the attributes, but since there are 197 buckets to search through
for each attribute, it's taking alot of time.
Our actual *overall* time improvement is a factor of two, but
theoretically, a reduction from 197 to 17 could be up to a factor of ten.
Thanks,
-Jeff
/* XNode inherits from DomNode */
static void XmluWriteNode(FILE* outFile, int depth, XNode* node) {
char* nodeName ;
nodeName = node->GetNodeName();
fprintf(outFile, "%s<%s", prefix[depth], nodeName);
/// print attribute list, if any
DOMNamedNodeMap* attribs = node->getAttributes() ;
if (attribs != NULL) {
int numAttribs = attribs->getLength() ;
for (int i = 0; i < numAttribs; i++) {
DOMNode* attr = attribs->item(i);
char* attrName = XMLString::transcode(attr->getNodeName()) ;
char* attrValue;
node->GetAttributeValue(attrName, attrValue) ;
fprintf(outFile, " %s=\"%s\"", attrName, attrValue) ;
XMLString::release(&attrName) ;
XMLString::release(&attrValue) ;
}
}
if (node->hasChildNodes()) {
/* recursive stuff */
}
}
Alberto Massari (JIRA) wrote:
[
http://issues.apache.org/jira/browse/XERCESC-1452?page=comments#action_12314869
]
Alberto Massari commented on XERCESC-1452:
------------------------------------------
Hi Jeff,
the DOMNamedNodeMapImpl class is not used to store attributes in an
element (that's DOMAttrMapImpl); it is used to store the list of
entities, notations and elements in a DTD. Can you double check why
reducing the size of these 3 maps improves your performances?
Thanks,
Alberto
DOMNamedNodeMapImpl::item() 10x preformance improvement
-------------------------------------------------------
Key: XERCESC-1452
URL: http://issues.apache.org/jira/browse/XERCESC-1452
Project: Xerces-C++
Type: Improvement
Components: DOM
Versions: 2.6.0
Environment: All environments
Reporter: Jeff Keasler
10 second bug fix -- change MAP_SIZE constant in
DOMNamedNodeMapImpl.hpp from 193 to 17.
I use literally millions of DomNodes each having 2-10 attributes
and DOMNamedNodeMapImpl::item() is horribly implemented. It makes
sense to fix the problem by changing the definition of MAP_SIZE to
17. Even people with 50 attributes will get decent performance if
you make this change, wheras the vast majority of people who only
use 5-10 will see up to a 10x performance improvement.
Thank you.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]