JMH benchmark of Java object-to-object mapping frameworks
Java Gnuplot
Switch branches/tags
Nothing to show
Clone or download
Latest commit 0df0d59 Feb 5, 2018

readme.md

Object-to-object mapping framework microbenchmark

Multi-layered applications often require to map between different object models (e.g. DTOs and entities). Writing such boiler plate mapping code is a tedious and error-prone task. A lot of object-to-object mapping Java frameworks aims to simplify this work and automate it. Some uses code instrospection (eg. Dozer). Other uses code generation (ex: MapStruct). This micro-benchmark compares performance of 6 frameworks. Results could be compared to the benchmark of a code written manually.

Benchmark are powered by a tool called JMH or also known as "Java Microbenchmarking Harness". JMH is developed by the OpenJDK team.

Benchmarked object to object mapper frameworks

Contributing to benchmark

Github is for social coding platform: if you want to add another mapping framework or optimize an existing one, we encourage contributions through pull requests from forks of this repository. If you want to contribute code this way, please reference a GitHub ticket as well covering the specific issue you are addressing.

Data model

The data model used by this benchmark is very basic. It comes from the Comparison class from the ModelMapper framework. It includes combinations which usually appear in Java Beans, such as:

  • Object types
  • Collections

Data model UML diagram

Launch the benchmark

Pre-requisites: Maven 3.x and a JDK 7 (or above)

git clone git://github.com/arey/java-object-mapper-benchmark.git

mvn clean install

java -jar target/benchmarks.jar

Optional: To run a single benchmark, such as MapStruct, use java -jar target/benchmarks.jar MapStruct

Interpreting the Results

The benchmarks measure throughput, given in "ops/time". The time unit used is seconds. Generally, the score represents the number of graph object mapped per second; the higher the score, the better.

Results

Tests has been performed on:

  • OS: macOS High Sierra
  • CPU: 3.1 GHz Intel Core i7, 2 cores, L2 Cache (per Core): 256 KB, L3 Cache: 4 MB
  • RAM: 16 GB 1867 MHz DDR3
  • JVM: Oracle 1.8.0_74-b02 64 bits
BenchmarkModeSamplesScoreMargin error (+/-)Units
Manualthrpt20027 598 750346 265ops/s
MapStructthrpt20027 206 021133 009ops/s
Selmathrpt20026 205 612185 326ops/s
JMapperthrpt20023 377 962124 537ops/s
Orikathrpt2004 097 03021 220ops/s
ModelMaperthrpt200323 7913 172ops/s
Dozerthrpt20084 113331ops/s

Framework Comparison

Documentation

Generating plot

  1. Run benchmark while exporting results to csv with java -jar target/benchmarks.jar -rff results.csv -rf csv
  2. Use gnuplot to generate plot with gnuplot benchmark.plt. This will output results.png.

Credits

  • Uses Maven as a build tool
  • Uses JMH for Java Microbenchmarking Harness