Performance issues in the XMLParser class

Jun 23, 2009 at 7:14 PM

The XMLParser class seems to have performance issues related to reconstruction of the GSA response XML string in the public StringBuilder sb instance variable. On parsing of GSA responses of 100+ results heavily peppered with metadata (read getfields=*), the parser may be taking upwards of 50 seconds to process the incoming stream. The issue is primarily stemming from inneffecient use of StringBuilder's Replace operation, which in many instances of usages may be refactored from

<font size="2">

Emit(sb +

</font>

" <" + sName + Attributes + ">" + LineEnd);

<font size="2" color="#0000ff"><font size="2" color="#0000ff">

private

</font></font><font size="2" color="#0000ff">

 

</font>

void Emit(string s) {

sb.Remove(0, sb.Length);

sb.Append(s);

}

to

<font size="2">

Emit(

</font>

" <" + sName + Attributes + ">" + LineEnd);

 

<font size="2" color="#0000ff"><font size="2" color="#0000ff">

private

</font></font><font size="2" color="#0000ff">

 

</font>

void Emit(string s) {

sb.Append(s);

}

Overall, the reconstruction of XML response functionality seems to be related to support of writing out responses to disk and may be entirely avoided by adding conditional handling into the StartElement(), EndElement() methods.

I maintainers of the project are interested, I will be glad to share the refactored class.

v