[xml] xmlTextReader performance question



I am switching to the reader API from XPath to improve performance. A lot of time is spent on processing a huge list of similar elements. The attributes of each element are what I am after. I notice a significant performance gain when I replace xmlTextReaderGetAttribute to a sequence of

MoveToAttribute
GetConstValue
MoveToElement

probably because there are very few possible values for the attributes in all my test documents. I understand it is very difficult to answer performance tradeoff questions and that could change in the future. I just hope someone can tell me a bit more what is happening here. Is there a hash/set for these 'const xmlChar *' strings so that allocation and deallocation are minimized? Or is it block allocation? If I know every attribute value is unique, would anyone recommend not using the MoveToAttribute approach? My program is multi-threaded and I really want to minimize allocation/deallocation.

I have a separate question. Can I save some allocation/deallocation if I use xmlReaderForMemory instead of xmlReaderForFile? I am thinking of memory mapping the whole file.

And thanks so much for libxml2.

Russell



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]