[jdom-interest] Speed!? JDOM vs DOM

Rolf Kluge rolf at smb-tec.com
Tue Mar 6 06:16:56 PST 2001


Hi all,
I am totally new in the list.
I have read something about JDOM in past and I tried to replace my DOM stuff
with the "lightweight, clean, productive and comfortable" JDOM.

So I start playing with it. First I want to compare the performance between
DOM and JDOM. I thought that JDOM would be much faster than DOM, but it is not.
Maybe I do something wrong!?

My comparison:
I compare how much time it takes to build an org.jdom.Document on the one hand and an
org.w3c.dom.Document on the other hand (from an xml-file).

e.g.:

The xml-file: file.xml (18.000 lines / 13.000 elements)

//
// For building org.jdom.Document.
//
FileInputStream in = new FileInputStream(filename);
SAXBuilder b;
b = new SAXBuilder("org.apache.xerces.parsers.SAXParser");
Document jdoc = b.build(in);

/* This takes about 12 sec. */


//
// For building org.w3c.dom.Document.
//
FileInputStream in = new FileInputStream(filename);
InputSource is = new InputSource(in);

org.apache.xerces.parsers.DOMParser parser;
parser = new DOMParser();
parser.parse(is);
Document doc = parser.getDocument();

/* This takes only 7 sec. */


So, what is the advantage of JDOM when it is so much slower than DOM??

Regards!
Rolf

______________________________________________________________________
Rolf Kluge                                     mailto:rolf at smb-tec.com
SMB GmbH                                        http://www.smb-tec.com




More information about the jdom-interest mailing list