Skip to content

Comparison with FasterXML Jackson

Mitchell Hentges edited this page Apr 7, 2016 · 6 revisions

v1.3.0

Comparison (lower is better):

v1.2.0

Comparison (lower is better):

Explanation

To get these results, I parsed the following JSON:

{\"a\":true, \"foo\": \"confirmed\", \"bar\": -3.642}

The full Java script is:

public static void main(String[] args) throws IOException {
    String toParse = "{\"a\":true, \"foo\": \"confirmed\", \"bar\": -3.642}";

    int iterations = Integer.parseInt(args[0]);
    ObjectMapper mapper = new ObjectMapper();
    JsonParse parse = new JsonParse();

    long start = System.currentTimeMillis();

    for (int i = 0; i < iterations; i++) {
        try {
            mapper.readValue(toParse, new TypeReference<Map<String, Object>>(){});
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    long fasterXml = System.currentTimeMillis() - start;
    start = System.currentTimeMillis();

    for (int i = 0; i < iterations; i++) {
        parse.map(toParse);
    }

    long jsonParse = System.currentTimeMillis() - start;
    System.out.printf("%d\t%d\t%d\n", iterations, fasterXml, jsonParse);
}

This program accepted a single argument - the number of times to parse the JSON. I used a small bash script to incrementally try more iterations:

#!/bin/bash

echo "Count   |FasterXML(ms)|JsonParse(ms)";

i="10"
while [ $i -le 10000000 ]
do
	java -jar target/json-parse-${VERSION}-jar-with-dependencies.jar $i
	let i*=10
done
Clone this wiki locally