You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Rainer Schwarze <rs...@admadic.de> on 2008/08/03 23:01:26 UTC

Performance of XmlCursor.comparePosition?

Hi,

Short version: I probably ran into performance issues of 
XmlCursor.comparePosition . Is there a way to speed things up?
(I'm using XmlBeans 2.3)

The details with more questions:

Lets assume I have a document like this:

<a>
   <b>
     ...
     <c>
       <d ... />
     </c>
     ...
   </b>
   ...
</a>

There are 1000 <b>'s, not all of them have the <c>'s, eventually I have
500 <d>'s. I have a list of XmlCursor instances pointing to all <d>'s
(listOfDs - this is sorted). After modifying the document I want to
update listOfDs for the range which changed.

I created iterators which loop through tokens from a start cursor to an
end cursor and use XmlCursor.isLeftOf to check when the end is reached.
I use Collections.binarySearch to find index into listOfDs with a
Comparator which uses XmlCursor.comparePosition.

When the document and the number of XmlCursors in listOfDs grows, the
comparison methods run much slower (for instance from 30 us to 230 us
with 1000 <b>'s and this won't be nice for - say - 10000 <b>'s).

Is this plausible? (Or do I have another issue, which may cause this
effect?)

Is there a way to speed things up? (For instance: Are comparisons
between certain XmlCursor locations faster than others?)

I dug my way through the XmlBeans sources to 
...impl.store.Cur.comparePosition .  There's a while loop at the end of 
the method which traverses a (doubly) linked list and I suspect that 
this is what I am hitting when I have a lot of elements. However, I'm 
not sure, because Cur and Xobj are quite large and not trivial :-)

Thanks in advance.

Best wishes, Rainer
-- 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org