[jdom-interest] AttributeList performance

Tatu Saloranta cowtowncoder at yahoo.com
Thu Apr 28 13:21:58 PDT 2005


--- Elliotte Harold <elharo at metalab.unc.edu> wrote:
> Victor Toni wrote:
> 
> > Therefore I suggested an additional class for
> qualified names. It would 
> > help creating other access mechanisms. The current
> 
> > Element.getAttribute(name) is O(N) but could be
> O(log(n)). Surely this 
> > change would be mainly for cases where there are a
> lot of atrributes but 
> > it would hurt simple documents?
> 
> While this might be asymptotically faster, I suspect
> in most use cases 
> the current implementation is quite a bit faster.
> For small values of N, 
> the constants matter.

And probably most importantly, there is constant
overhead for creating the Map structure. What might
make sense (if one wanted to create an elaborate
optimization...) would be to construct such a
structure only if/when needed (based on first or
second access, and perhaps number of attributes too).
But whether that'd be worth the effort... for
lightning-fast processing, one probably won't be using
DOM approach in any case. ;-)

As to the access time itself, I'm fairly confident
that the HashMap solution is pretty much always faster
for even fairly small sets (3 or more entries).
But the performance benefit of just the access itself
has to outweigh memory and speed overheads of creating
HashMap which is more heavy-weight than a simple
array/List.

-+ Tatu +-


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the jdom-interest mailing list