Java Mailing List Archive

http://www.junlu.com/

Home » JDOM Projects »

[jdom-interest] Performance: JDOM2 and Saxon

Michael Kay

2011-10-24

Replies: Find Java Web Hosting

Author LoginPost Reply
My colleague O'Neil Delpratt has been doing some performance experiments
with JDOM1 and JDOM2. Here are the results he is getting.



Experiment: I ran a somewhat simplified test harness on the same two
XPath expression (i.e. "//@(protected)
hamlet.xml

Results
Average time taken over 50 runs, excluding the first run.

JDOM1: 273.15ms
JDOM2: 92.56ms
Saxon (TinyTree treeModel): 2.8ms
Saxon (JDOM treeModel): 10.36ms
Saxon (JDOM2 treeModel): 10.82ms

The # of tree nodes:
Saxon: 12097
Standalone JDOM(-2): 19840

The difference in results was down to whitespace between elements
represented as text nodes in JDOM(-2).

So: JDOM2 is doing a good job relative to JDOM1, but the XPath engine is
still very slow compared to Saxon's XPath engine.

The Saxon code for accessing JDOM2 uses the JDOM node.getDescendants()
method rather than making recursive use of getChildren() as we do with
JDOM1, and this benefits performance in that without this change, the
JDOM2 code ran in 12.28ms; but we're still getting slightly slower
results from JDOM2 despite this improvement.

I believe the way the measurements were done causes the XPath expression
to be compiled once and executed repeatedly.

The differences we are seeing from these results are:

(a) The TinyTree is very fast when processing the descendant axis
(because the nodes are held in an array in document order)

(b) In the scenario where XPath compile time is amortized over many
executions (the only case we've measured), the Saxon XPath engine is
much faster than the one built in to JDOM.

(c) JDOM2 is fractionally slower than JDOM1 in its navigational APIs,
even though its XPath engine is now three times faster.

Michael Kay
Saxonica
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
©2008 junlu.com - Jax Systems, LLC, U.S.A.