Benchmark results are always dependent on a very individual setup. Normally it is not useful to generalize such results for every use case, but it can give you a hint. However, if you're really in the need of maximum performance, you should probably create an own benchmark with your objects or even use a profiler to detect the real hot spots in your application.
XStream uses the Java Microbenchmark Harness (JMH) of the JDK Tools as benchmark framework starting with version 1.4.9. As result it contains a ZIP file (xstream-jmh-<version>-app.zip) as new artifact containing anything required to run the benchmarks. Unpack the file and use the scripts in the bin directory to execute the benchmarks. Use option -h to look at the options provided by JMH. You may exchange the libraries in the lib directory with other versions of XStream or the individual parsers or you may even add new JMH benchmarks to the default ones of XStream.
All benchmark values below measure the average throughput in nanosecond per operation. JMH provides additional measurement options, see online help. The maximum deviation for each benchmark is recorded in the reference files of the distributed ZIP file. The benchmark is executed on Linux 4.1.12 Gentoo 64-bit system with an Intel Core i7 CPU 920 of 2.67 GHz. Note again, that these values are no replacement for real profiler results and they may vary from run to run (see reference files) due to this machine's background processes on a single CPU. However, it can give you some idea of what you can expect using different parser technologies.
The values represent the average throughput of 15 runs with a single thread. The benchmarks emphasis the parser efficiency for different structures.
Parser | Text | Array | Nested |
---|---|---|---|
W3C DOM (Oracle JDK 1.8.0_66) | 10037380.795 | 54234293.351 | 1917332.056 |
JDOM (1.1.3) | 6368317.636 | 7910979.223 | 3862796.027 |
JDOM 2 (2.0.5) | 5767640.105 | 10570210.653 | 2980906.727 |
DOM4J (1.6.1) | 7816280.084 | 92998322.952 | 2108075.646 |
XOM (1.1) | 7950778.533 | 38704485.310 | 2471019.743 |
StAX (BEA 1.2.0) | 3108517.699 | 1310406.961 | 669111.164 |
StAX (Woodstox 3.2.7) | 1884858.525 | 1240767.393 | 650470.623 |
StAX (Oracle JDK 1.8.0_66) | 7366387.272 | 1334398.501 | 688229.709 |
XPP (Xpp3 min 1.1.4c) | 2109341.076 | 1309607.210 | 3301732.767 |
XPP (kXML2 min 2.3.0) | 3391204.266 | 1514514.680 | 8105934.241 |
Binary (XStream 1.4.9) | 1144243.750 | 1062031.901 | 496839.565 |
Jettison (1.2) | 3002547.220 | 1159238.555 | 682182.733 |
The values represent the average throughput of 16 runs with four threads using the Xpp3 parser for a structure with 1.000 elements. The benchmarks demonstrate the different converter types that can be used for a standard Java class.
Converter Type | Throughput |
---|---|
Custom | 11276718.384 |
Java Bean | 28878706.293 |
Reflection | 40085786.696 |
The values represent the average throughput of 16 runs with four threads using the Xpp3 parser for a structure with 10.000 string elements of various sizes and duplicates. The benchmarks demonstrate different implementations and configurations of the StringConverter.
StringConverter Strategy | Throughput |
---|---|
No Cache | 19626160.696 |
Intern | 23060982.052 |
ConcurrentMap (length limit) | 21796001.29 |
ConcurrentMap (unlimited) | 21378299.003 |
Sync'd WeakCache (length limit) | 21838410.801 |
Sync'd WeakCache (unlimited) | 22011251.691 |
The values represent the average throughput of 25 runs with four threads using the Xpp3 parser for a structure with 250 nested elements using names invalid for XML elements. The benchmarks demonstrate different implementation strategies for a NameCoder to create valid tag names in XML.
NameCoder Implementation | Throughput |
---|---|
No Coding | 7299475.975 |
Dollar Coding | 7767196.902 |
Escaped Underscore Coding | 9894393.289 |
Cached Escaped Underscore Coding | 7867671.962 |
Xml Friendly Coding | 8635501.208 |