This project benchmarks common data serialization formats using JMH.
The sample data is taken from here.
- Cap’n Proto
- EXI
- Fast Infoset
- Json (using Jackson)
- MessagePack
- Protostuff
- Protocol Buffers
- Apache Thrift
- XML (using JAXB, JAXB with Aalto, Jackson)
- Java Object serialization (functions as control group)
Thrift is a special case, because its code generator maven plugin expects the path of an installed Thrift library. Make sure it is installed.
- Byte array (in memory) to Java Object
- Byte array (in memory, compressed with gzip) to Java Object
- Java Object to Byte array (in memory)
- Java Object to Byte array (in memory, compressed with gzip)
- JDK 11
- Maven
-
Build the project (a self-contained executable JAR, which holds the benchmarks):
# mvn package
-
Run all benchmarks:
# java -jar target/serialization-format-benchmarks.jar
Usage with options (
java -jar target/serialization-format-benchmarks.jar info
prints the following):Usage: serialization-format-benchmarks [options] Options: -c, --comp Benchmark with no compression (without), compression (with) or both (both) Default: both Possible Values: [without, with, both] -e, --exclude Comma separated regex list to exclude benchmarks from the run. Default: [] -i, --include Comma separated regex list to include benchmark in the run. Default value runs all benchmarks Default: [Benchmarks]
Results of a benchmark run on a 2018 MacBook Pro (2.6 GHz Intel Core i7, 16 GB DDR4) with OpenJDK 11 can be found here.