[jdom-interest] New benchmark
KUMAR,PANKAJ (HP-Cupertino,ex1)
pankaj_kumar at hp.com
Tue Jul 2 22:48:50 PDT 2002
Hi Jason, Brad,
Thanks for bringing this to my notice. Brad's analysis is correct. I have
submitted a bug (
https://sourceforge.net/tracker/index.php?func=detail&aid=576754&group_id=37
214&atid=419698 ) and have added the following note:
============================================================================
==
Verified as a problem in JDOMProcessor.java code.
Measurements with indexed traversal ( original ) and iterator
traversal (modified) confirm that the non-linear performance
degradation happens with indexed traversal. XStat Processing
time ( in ms ) for three files generated by rxgen of sizes
99KB, 984 KB and 1984KB were observed as:
99KB 984KB 1984KB
Original -----> 65 -------- 1000 ---------- 3250
Modified ----> 62 -------- 422 ----------- 828
Action Items:
-------------------
(i) check-in the modified code to CVS.
(ii) Put a note at XPB4J measurements document.
(iii) Update the measurements document with new readings in
the next revision cycle.
Few thoughts
-------------------
It is appropriate to use the most efficient algorithm/interfaces
offerred by a particular API. However, the reason
JDOMProcessor had indexed traversal code was that I
modified the code for DOM based processing with least
amount of changes -- something that other folks may also do.
Other thing is that though XStat processing requires only
linear scan, other applications might required more frequent
indexed access. Those applications could suffer under
current implementation.
A better solution may be to have List implementation used by
JDOM be optimized for indexed access as well as iterator
based access.
=======================================================================
Pankaj Kumar
-----Original Message-----
From: Bradley S. Huffman [mailto:hip at a.cs.okstate.edu]
Sent: Tuesday, July 02, 2002 1:01 PM
To: Jason Hunter
Cc: jdom-interest at jdom.org; hip at a.cs.okstate.edu
Subject: Re: [jdom-interest] New benchmark
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