axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aleksander Slominski <as...@cs.indiana.edu>
Subject Re: FYI : JDOM vs. DOM
Date Tue, 03 Apr 2001 18:30:13 GMT

gdaniels@macromedia.com wrote:

> With JDOM, the first run took 16ms.  The next 9 were all the same, 0ms.

that is pretty blazing speed (0ms?) so i got very curious here are snippets from your code:


     try {
            DOMParserWrapper parser =
            (DOMParserWrapper)Class.forName(parserWrapperName).newInstance();
            DOMCount counter = new DOMCount();
            long before = System.currentTimeMillis();
            parser.setFeature( "http://apache.org/xml/features/dom/defer-node-expansion",

                               setDeferredDOM );
            parser.setFeature( "http://xml.org/sax/features/validation",
                               setValidation );
            parser.setFeature( "http://xml.org/sax/features/namespaces",
                               setNameSpaces );
            parser.setFeature( "http://apache.org/xml/features/validation/schema",
                               setSchemaSupport );

            Document document = parser.parse(uri);
            counter.traverse(document);
            long after = System.currentTimeMillis();
            counter.printResults(uri, after - before);
        } catch (org.xml.sax.SAXParseException spe) {

so in DOM case you measure Document tree creation (parser.parse(uri)) _and_ traversing
(counter.traverse(document);)


        try {
            SAXBuilder builder = new SAXBuilder();
            Document document = builder.build(uri);
            JDOMCount counter = new JDOMCount();
            long before = System.currentTimeMillis();

            counter.traverse(document.getRootElement());
            long after = System.currentTimeMillis();
            counter.printResults(uri, after - before);
        } catch (Exception e) {
            e.printStackTrace(System.err);
        }

however for JDOM you have excluded Document tree creation from time measuring (Document document
= builder.build(uri)) and only included (counter.traverse(document.getRootElement());).

so i would say walking _already_ constructed tree of 4 elements should be pretty fast (and
i
guess as well for DOM...).

thanks,

alek
--
Aleksander Slominski, LH 316, IU, http://www.extreme.indiana.edu/~aslom
As I look afar I see neither cherry Nor tinted leaves Just a modest hut
on the coast In the dusk of Autumn nightfall - Fujiwara no Teika (1162-1241)



Mime
View raw message