JDOM2 Relative JDK Performance
Java manipulation of XML made easy.
The following is a basic metric of the performance characteristics of JDOM2.
The identical code/classes are run in Java5, Java6, and Java7. The code is
compiled by Java6 JDK with a 1.5 .class target.
This is not meant to be a reproducable baseline, rather, it is intended to
give an idea of whether a change has improved or decreased the performance.
For details of the actual test cases have a look at the
Peformance Page
The following metrics are (currently) produced:
- Input - number of bytes in the input XML files
- Mem - the amount of memory required to load the XML as a JDOM document
- SAX - The SAXBuilder.build() method is timed
- SAXJ - the amount of SAX time in JDOM
- DOM - The DOMBuilder.build() time
- DOMJ - the amount of DOM time in JDOM
- StAXS - The StAXBuilder.build(XMLStreamReader) time
- StAXSJ - the amount ot StAXS timm in JDOM
- StAXE - The StAXBuilder.build(XMLEventReader) time
- StAXEJ - the amount ot StAXE time in JDOM
- Scan - It measures how long it takes to do a simple, and then an Element-Filtered
DescendantIterator 'walk' of the document tree.
- Dump - It measures how long it takes to output the document to a 'bitbucket'
in the three major Format outputs (pretty, compact, raw).
- Dupe - It measures how long it takes to recursively 'duplicate' the document
by using a 'brute-force' mechanism which uses the 'new' constructors for
the content. See the code for what it does.
- XPath - It measures how long it takes to do two XPath operations, one that selects
all attributes with a non-existing name (expect no results). The other
selects all Elements.
- Checked - It measures how long it takes to send the document back through the
SAXOutputter/SAXHandler using the DefaultJDOMFactory
- UnChecked - It measures how long it takes to send the document back through the
SAXOutputter/SAXHandler using the UncheckedJDOMFactory
The following tests were run one after the next, on my laptop.
JDK5 with Java5 Results
Java 1.5.0_21 with Java5 targetted JDOM
Input | JDOM | SAX | SAXJ | DOM | DOMJ | StAXS | StAXSJ | StAXE | StAXEJ | Scan | Dump | Dupe | XPath | Checked | UnChecked |
273.14KiB | 1.98MiB | 12.75ms | 5.73ms | 18.36ms | 7.98ms | 13.08ms | 6.16ms | 25.69ms | 9.98ms | 8.13ms | 24.91ms | 25.87ms | 384.40ms | 30.74ms | 23.44ms |
273.14KiB | 1.98MiB | 12.53ms | 5.61ms | 19.13ms | 8.79ms | 13.21ms | 5.95ms | 25.61ms | 10.09ms | 7.83ms | 24.65ms | 23.70ms | 377.92ms | 27.90ms | 22.11ms |
273.14KiB | 1.98MiB | 12.57ms | 5.58ms | 19.58ms | 9.19ms | 13.38ms | 6.25ms | 24.74ms | 10.04ms | 7.86ms | 24.92ms | 25.22ms | 375.03ms | 31.22ms | 23.46ms |
273.14KiB | 1.98MiB | 12.32ms | 5.44ms | 17.75ms | 7.53ms | 12.82ms | 5.37ms | 23.18ms | 8.10ms | 7.46ms | 25.11ms | 22.37ms | 378.41ms | 31.12ms | 22.99ms |
273.14KiB | 1.98MiB | 12.62ms | 5.60ms | 19.15ms | 8.78ms | 13.07ms | 5.95ms | 28.35ms | 13.43ms | 7.93ms | 25.67ms | 23.87ms | 375.18ms | 27.90ms | 22.81ms |
JDK5 with Java6 Results
Java 1.6.0_26 with Java5 targetted JDOM
Input | JDOM | SAX | SAXJ | DOM | DOMJ | StAXS | StAXSJ | StAXE | StAXEJ | Scan | Dump | Dupe | XPath | Checked | UnChecked |
273.14KiB | 2.27MiB | 5.30ms | 1.41ms | 7.41ms | 2.59ms | 5.56ms | 1.24ms | 10.51ms | 3.19ms | 3.26ms | 12.82ms | 10.71ms | 74.05ms | 12.29ms | 10.40ms |
273.14KiB | 2.27MiB | 5.42ms | 1.40ms | 7.29ms | 1.93ms | 5.57ms | 0.96ms | 10.35ms | 3.00ms | 3.31ms | 13.37ms | 10.86ms | 73.27ms | 12.24ms | 9.77ms |
273.14KiB | 2.27MiB | 5.70ms | 2.18ms | 7.38ms | 2.78ms | 5.37ms | 1.16ms | 9.58ms | 2.40ms | 3.21ms | 12.49ms | 11.03ms | 72.08ms | 12.67ms | 10.07ms |
273.14KiB | 2.27MiB | 5.07ms | 1.73ms | 7.36ms | 2.80ms | 5.59ms | 1.43ms | 10.68ms | 3.26ms | 3.46ms | 13.31ms | 11.00ms | 72.38ms | 12.23ms | 10.75ms |
273.14KiB | 2.27MiB | 5.35ms | 1.69ms | 7.41ms | 2.72ms | 5.48ms | 1.09ms | 10.63ms | 3.54ms | 3.36ms | 13.28ms | 11.66ms | 73.99ms | 12.06ms | 10.55ms |
JDK5 with Java7 Results
Java 1.7.0 (b147) with Java5 targetted JDOM
Input | JDOM | SAX | SAXJ | DOM | DOMJ | StAXS | StAXSJ | StAXE | StAXEJ | Scan | Dump | Dupe | XPath | Checked | UnChecked |
273.14KiB | 2.27MiB | 5.76ms | 1.95ms | 8.52ms | 3.40ms | 5.73ms | 1.41ms | 10.29ms | 3.35ms | 3.43ms | 13.05ms | 10.53ms | 31.12ms | 11.82ms | 10.02ms |
273.14KiB | 2.27MiB | 5.16ms | 0.60ms | 7.93ms | 2.85ms | 5.59ms | 0.91ms | 10.36ms | 2.96ms | 3.41ms | 13.39ms | 10.50ms | 29.80ms | 13.61ms | 10.26ms |
273.14KiB | 2.27MiB | 4.91ms | 0.83ms | 8.02ms | 2.83ms | 6.24ms | 1.78ms | 9.17ms | 2.15ms | 3.55ms | 14.17ms | 10.19ms | 29.96ms | 11.63ms | 10.40ms |
273.14KiB | 2.27MiB | 5.20ms | 1.50ms | 7.99ms | 3.20ms | 6.04ms | 2.11ms | 10.41ms | 3.57ms | 3.33ms | 13.29ms | 9.90ms | 29.53ms | 11.15ms | 9.80ms |
273.14KiB | 2.27MiB | 5.06ms | 1.63ms | 8.46ms | 3.41ms | 5.78ms | 1.71ms | 9.56ms | 2.61ms | 3.34ms | 14.30ms | 10.10ms | 30.48ms | 11.49ms | 9.96ms |
JDK6 with Java6 Results
Java 1.6.0_26 with Java6 targetted JDOM
Input | JDOM | SAX | SAXJ | DOM | DOMJ | StAXS | StAXSJ | StAXE | StAXEJ | Scan | Dump | Dupe | XPath | Checked | UnChecked |
273.14KiB | 2.27MiB | 5.16ms | 1.69ms | 7.32ms | 2.44ms | 5.49ms | 0.84ms | 10.50ms | 3.71ms | 3.31ms | 12.47ms | 11.01ms | 71.70ms | 12.06ms | 10.39ms |
273.14KiB | 2.27MiB | 5.68ms | 1.90ms | 7.63ms | 2.72ms | 5.35ms | 1.05ms | 10.54ms | 3.51ms | 3.14ms | 12.82ms | 10.50ms | 73.70ms | 11.73ms | 9.75ms |
273.14KiB | 2.27MiB | 5.64ms | 1.53ms | 7.55ms | 2.95ms | 5.19ms | 1.04ms | 9.73ms | 2.53ms | 3.25ms | 12.21ms | 10.64ms | 75.50ms | 12.31ms | 10.26ms |
273.14KiB | 2.27MiB | 5.31ms | 1.74ms | 7.34ms | 2.83ms | 5.17ms | 0.91ms | 10.09ms | 3.09ms | 3.24ms | 13.39ms | 10.73ms | 73.57ms | 12.40ms | 10.09ms |
273.14KiB | 2.27MiB | 5.30ms | 2.13ms | 7.10ms | 2.50ms | 5.27ms | 1.05ms | 9.51ms | 2.64ms | 3.49ms | 13.51ms | 10.38ms | 73.51ms | 11.98ms | 10.06ms |
JDK6 with Java7 Results
Java 1.7.0 (b147) with Java6 targetted JDOM
Input | JDOM | SAX | SAXJ | DOM | DOMJ | StAXS | StAXSJ | StAXE | StAXEJ | Scan | Dump | Dupe | XPath | Checked | UnChecked |
273.14KiB | 2.27MiB | 5.46ms | 1.80ms | 7.36ms | 2.50ms | 5.40ms | 1.03ms | 9.88ms | 2.55ms | 3.42ms | 13.73ms | 10.52ms | 29.79ms | 11.52ms | 10.35ms |
273.14KiB | 2.27MiB | 5.32ms | 1.34ms | 7.40ms | 2.15ms | 5.00ms | 0.64ms | 9.73ms | 2.67ms | 3.12ms | 13.48ms | 11.20ms | 29.87ms | 12.56ms | 10.13ms |
273.14KiB | 2.27MiB | 5.48ms | 1.67ms | 7.98ms | 3.33ms | 5.84ms | 1.77ms | 8.99ms | 2.56ms | 3.45ms | 12.91ms | 10.62ms | 30.07ms | 12.54ms | 11.30ms |
273.14KiB | 2.27MiB | 5.36ms | 2.00ms | 7.79ms | 2.93ms | 5.77ms | 1.51ms | 10.46ms | 3.85ms | 3.35ms | 14.72ms | 10.66ms | 30.72ms | 12.70ms | 10.26ms |
273.14KiB | 2.27MiB | 5.22ms | 1.86ms | 7.58ms | 2.49ms | 5.48ms | 1.07ms | 9.69ms | 2.26ms | 3.21ms | 13.04ms | 10.67ms | 29.15ms | 12.11ms | 11.95ms |