Performance Comparison of JSON Libraries: Jackson vs gson vs fastjson vs JSON.simple vs JSONP

The purpose of this project is to evaluate serialization and deserialization performance of JSON libraries in Java.

The results here-below were computed on May the 21st, 2017 with the following libraries and versions:


LibraryVersion
jackson2.9.4
genson1.4
fastjson1.2.32
gson2.8.2
org.json20090211
javax-json1.0, 1.0.4
json-io4.9.12
flexjson3.3
boon0.34
json-smart2.3
johnzon1.1.0
logansquare1.3.7
dsl-json1.7.0
simplejson1.1.1
nanojson1.2
jodd json3.8.5
moshi1.5.0
tapestry5.4.3
jsoniter0.9.11

 

This benchmark tests throughput performance of serialization and deserialization algorithms of the databind and stream API when available. Random payloads of various sizes are generated at runtime before each benchmark.

Four different sizes of payloads are evaluated in the charts below: 1 KB, 10 KB, 100 KB and 1 MB. And it is possible to generate on the fly any size of payloads.

Each benchmark is written to read bytes from RAM and write to reusable output streams in RAM when possible, strings are rarely generated. All data is randomly generated upon static loading.

This benchmark does NOT evaluate:

1. compression performance or efficiency
2. payloads bigger than 1.1 MB (would be easy to do though)
3.RAM utilization

Benchmark configuration

The benchmarks are written with JMH and for Java 8.

JMH

# JMH version: 1.19# VM version: JDK 1.8.0_121, VM 25.121-b13# VM invoker: /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/bin/java# VM options: -XX:+AggressiveOpts -Xms2G -Xmx2G# Warmup: 5 iterations, 1 s each# Measurement: 10 iterations, 3 s each# Timeout: 10 min per iteration# Threads: 16 threads, will synchronize iterations# Benchmark mode: Throughput, ops/time

Hardware

Model Name: MacBook ProProcessor Name: Intel Core i7Processor Speed: 2.6 GHzNumber of Processors: 1Total Number of Cores: 4L2 Cache (per Core): 256 KBL3 Cache: 6 MBMemory: 16 GB

Result:

Serialization performance

Serialization performance
Serialization performance

Deserialization performance

Deserialization performance
Deserialization performance

 


References: