Skip to content

pedes/jsonb-benchmark

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON-B Benchmark Project

This project benchmarks JSON-B RI and Jackson operations. Scores are in throughput (ops/ms)

Running Benchmarks
mvn clean install exec:java -Dexec.mainClass="org.istanbuljug.json.RunBenchmarks"

Benchmark #1

Java Object to JSON
Jug jug = new Jug("İstanbul JUG", 2010);

//JSON-B
Jsonb jsonb = JsonbBuilder.create();
String json = jsonb.toJson(jug);

// Jackson
ObjectMapper objectMapper = new ObjectMapper();
String json = objectMapper.writeValueAsString(jug);
Result #1
Benchmark                            Mode  Cnt     Score     Error   Units

SerializeBenchmark.jackson_to_json  thrpt   10  2883,464 ± 427,658  ops/ms
SerializeBenchmark.jsonb_to_json    thrpt   10   372,921 ±  57,550  ops/ms

Benchmark #2

JSON to Java Object
String jug = "{\"name\":\"İstanbul JUG\",\"year\":2010}";

//JSON-B
Jsonb jsonb = JsonbBuilder.create();
Jug jug = jsonb.fromJson(jug, Jug.class);

// Jackson
ObjectMapper objectMapper = new ObjectMapper();
Jug jug = objectMapper.readValue(jug, Jug.class);
Result #2
Benchmark                              Mode  Cnt     Score     Error   Units

DeserializeBenchmark.json_to_jackson  thrpt   10  2259,487 ± 852,504  ops/ms
DeserializeBenchmark.json_to_jsonb    thrpt   10   374,747 ±  41,455  ops/ms

Hot Methods

JSON-B RI Stack Profiler Result

85,4%  85,4% java.lang.Class.getEnclosingMethod0
7,4%   7,4% java.lang.Class.getDeclaringClass0
1,1%   1,1% org.*.SerializerBuilder.getSupportedTypeSerializer
1,1%   1,1% java.util.stream.AbstractPipeline.wrapSink
0,7%   0,7% org.glassfish.json.JsonGeneratorImpl.writeString
0,6%   0,6% org.*.Marshaller.serializeRoot
0,4%   0,4% org.*.LexicographicalOrderStrategy.lambda$sortProperties$40
0,3%   0,3% org.*.SerializeBenchmarkStackProfiler.jsonb_to_json
0,3%   0,3% org.glassfish.json.JsonGeneratorImpl.close
0,3%   0,3% java.util.concurrent.ConcurrentLinkedQueue.poll
2,4%   2,4% <other>

About

JSON-B Benchmark Project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 98.3%
  • Shell 1.7%