[jdom-interest] New benchmark

Jason Hunter jhunter at servlets.com
Tue Jul 2 14:07:53 PDT 2002


Thanks for digging into this, Brad.  I've sent him an email.  It's
actually a little scary to have a benchmark author using size() in the
for loop.  I was scolded away from doing that my first week as a
professional programmer.  Doing size() on top of get(i) is death using
FilterList.  No wonder we slow down so much.

-jh-

"Bradley S. Huffman" wrote:
> 
> Jason Hunter writes:
> 
> > http://xmlhack.com/read.php?item=1706
> >
> > Interesting reading.  JDOM's looking pretty good (and that's
> > particularly impressive since b8 had the StringBuffer performance bug).
> >
> > But look at the last chart.  There's clearly some bug there we need to
> > track down!
> 
> Hmmm, looks more like a case of either not reading the docs., or us not
> being clear/obvious enough in our docs. But looking in
> org.xperf.xpb.xstat.jdom.JDOMProcessor.java, I see
> 
>   private void collectStat(Element elem, StatCollector sc)
>     {
>         sc.element(elem);
>         List children = elem.getChildren();
>         for (int i = 0; i < children.size(); i++)
>           collectStat((Element)children.get(i), sc);
>         }
> 
> However the javadocs for Element.getChildren() states
> 
>     Sequential traversal through the List is best done with a Iterator since
>     since the underlying implement of List.size() may not be the most efficient.
> 
> Bet you if the code is change to use a Iterator, the times would look a whole
> lot better.  Maybe a nice note to Mr. Kumar would be appropiate :)
> 
> Brad



More information about the jdom-interest mailing list