Skip to content

Latest commit

 

History

History
114 lines (74 loc) · 4.06 KB

README.md

File metadata and controls

114 lines (74 loc) · 4.06 KB

Benchmark for comparing JSON performance on Java platform

This project contains benchmark suite for comparing performance of JSON-to/from-POJOs data binding, using various Java JSON libraries.

Basics

Libraries included are mostly ones that can do fully automatic data-binding; but in some cases we may also include ones that only implement Tree-based processing, in which case additional manual coding is required. We may also include tree-based variants of data-binding - capable libraries in cases where that makes sense. In all cases we indicate processing-module uses (which indicates level-of-effort for using library for data-binding use cases).

Test framework

Tests use Japex, since it

  1. Is designed for full benchmark runs (not just micro-benchmarks), and
  2. It provides full JVM isolation between tests, to avoid Hot-Spot problems wrt multiple competing implementations

Some attempts were made to use Caliper, which has some promising features; but in the end Japex proved bit more mature for this specific use case. But we may try out other frameworks in future.

Results

Can be found from Wiki

Libraries included

Fastjson

Tested with default settings; except configured NOT to check for cyclic dependencies (as that adds overhead). Library apparently can not take streaming input, so code has to read all content in; this is done using simple copy (which gives slight advantage compared to having to do it the usual way); but should not change results drastically.

Flex-JSON

NOTE: version 3.0 appears to be available, but I could not make it work. 2.1 appears to be the official publicly available version.

Genson

Similar to GSON, need to use JDK InputStreamReader. In addition, output only as String, which is then written using OutputStreamWriter.

GSON

Tested in basic data-binding mode, with default configuration.

GSON does not take InputStream or OutputStream, so input is read using standard JDK InputStreamReader (with UTF-8) and output OutputStreamWriter.

Jackson

Tested in basic data-binding mode, with default configuration.

Note that tests does NOT use Afterburner module (which could increase speed by 30-40%) as the intent is to compare default implementations, configurations. A separate test driver may be added in future to test such variation.

JSON-tools

Seems to require two-phase process for reading (with JSONParser from InputStream, into JSONValue; then mapped using JSONMapper. Similarly writing has to be done using an intermediate String -- inefficient, but that's what API expects.

Libraries not included

Following libraries were considered for inclusion, but had to be excluded for some reason.

Json-lib

This library is sort-of kind-of capable of data-binding, but requires lots of additional configuration and registration of types (see JsonLibJsonDatabind.java of JVM-serializers for details); so it seems more hassle than worth. Performance, as per jvm-serializers, also does not rank anywhere near top of Java JSON libraries, so this does not seem like a big omission.

Json-smart

Simply, does not work. Although I found a way that should allow Bean conversions, code just mysteriously fails with a class-loading error.

If anyone can suggest a fix or work-around, I will be happy to include this in tests as well. Results from sources other than project home page suggest not-so-stellar performance (like jvm-serializers).