QDomDocument vs libxml2 on Performance



  • I have rewritten my old libxml2-based parser using QDomDocument. The parsing is done in somewhat different way than my old parser, as the purpose is to now have a nice GUI instead of just a command line tool. Unfortunately, the parsing has become really a lot slower: from less than a second with the old libxml2-based parser to 8+ minutes with the QDomDocument-based parser. Since this is a rather big difference, I was wondering whether QDomDocument is known to be slower than libxml2 for the very same parsing algorithm. Your comments are welcome.


  • Lifetime Qt Champion

    Hi,

    What size/complexity is your document ? One of the thing to take into account is that QDomDocument will load your complete file in-memory. Is this really what you need ?



  • One of the examples is 5MB in file size and that is by far not the biggest example that I have. I do need to go through the DOM tree a few times and sometime combine things at different places in the DOM tree to parse things correctly, so QXmlStreamReader is no option. My biggest worry is not so much the memory consumption (at least at the moment) but the time it takes...


  • Lifetime Qt Champion

    AFAIK, libxml2 outperforms QDomDocument.

    Depending on your needs, implementing a small wrapper around it might be better.

    What would your GUI do with these files ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.