[jdom-interest] jdom 1.1
Jason Hunter
jhunter at servlets.com
Mon Sep 8 17:06:41 PDT 2008
With this test code at http://jira.activemath.org/browse/OM-12 (based
on the original report) I don't see any difference between JDOM 1.0
and JDOM 1.1. After upping the memory given to Java, the load of the
25M file happens in 6 seconds under both versions. The full walk
takes 84 additional seconds, same on both versions. This is with
"1.5.0_13" on a modern MacBook Pro.
The "walking code" is slow at 84s but that's due to the test program's
code not being optimized:
List bookList=booksElement.getChildren("book");
int numberOfBooks=bookList.size();
for(int i=0;i<numberOfBooks;i++){
Element bookElement=(Element)bookList.get(i);
readPriceList(bookElement.getChild("price"));
}
It would be much, MUCH faster for user code to iterate over the books
directly rather than looking them up each time by index. Each numeric
index lookup requires a child-walk to find the item. It's an n-
squared algorithm. That's not a big deal with 5 items but with 50,000
items as with this test file, that's going to be slow. It's the same
on JDOM 1.0 and JDOM 1.1 both for me.
I rewrote the example to fix two main iterator loops and the full walk
now takes 0.1 seconds.
-jh-
P.S. The test code also uses == to compare Strings, which is a
potential unrelated problem:
List children=element.getChildren();
if(children !=null){
Iterator iterator=children.iterator();
while (iterator.hasNext()) {
Element child = (Element) iterator.next();
if(child.getName()=="date_created"){
readDate(child);
}else if(child.getName()=="date_modified"){
readDate(child);
On Sep 3, 2008, at 2:20 AM, katja.radelicki at colruyt.be wrote:
>
> Hello,
> I simplified my code and tested it again.
> You can find it here: http://jira.activemath.org/browse/OM-12
> It seems walking trough the JDOMTree generates the problem and not
> creating the JDOMTree.
> You can can find two programs:
>
> 1.JDomReaderSaxCreateJdomTree.java
> this program only reads the xml-document and creates the JDOMTree.
> Here seems to be no problem!
>
> 2.JDomReaderSax.java
> this program reads the xml-document,creates the JDOMTree and walks
> trough the jdomtree. I suppose walking trough the tree generates the
> problem in time.
>
> There are also 3 example xml files.
>
> I hope you can test the code. If there is a problem, just tell me.
>
> Thank you very much.
>
>
> ----- Original Message ---------------------------------
>
> Can someone tell me why jdom 1.1 is slower than jdom 1.0? Which
> changes are made that causes this?
>
> And why is jdom 1.1 is more memory intensive than jdom 1.0?
>
> Thanks a lot!
More information about the jdom-interest
mailing list