java icon indicating copy to clipboard operation
java copied to clipboard

Benchmark differences

Open re-thc opened this issue 5 years ago • 3 comments

Hi, the jsoniter websites claims it's quite a lot faster compared to Jackson. However as per https://github.com/fabienrenaud/java-json-benchmark -- Jackson seems to be faster in all the test cases. Are there any issues with the benchmark code or settings that need to be applied? Curious to know why there are such differences and which Json library we're currently considering to use.

Thanks.

re-thc avatar Jul 04 '18 06:07 re-thc

watching...

Kyson avatar Oct 09 '18 04:10 Kyson

@Kyson you can use async-profiler to get interactive flame graphs that will help to spot weak places easily.

Also, please look into the core module of jsoniter-scala.

It started from Scala macro that reused reader and writer from Jsoniter Java and generated codecs for them but then evolved to have own core module. Now it has lot of goodies that can be ported back to this library easily:

  • parsing and serialization of UUIDs at speed ~70 CPU cycles per value
  • serialization of floats and doubles into the most optimal representation using adopted Ryu routines at speed ~120 and ~280 CPU cycles per value accordingly
  • parsing and serialization of java.time.* classes from/to the ISO-8601 representation without redundant allocation of strings and even without / and % operators

plokhotnyuk avatar Oct 09 '18 10:10 plokhotnyuk

@Kyson Also, I have added Jsoniter Java to our benchmark suite using following adapters for parsing and serialization:

https://github.com/plokhotnyuk/jsoniter-scala/blob/master/jsoniter-scala-benchmark/src/main/java/com/jsoniter/input/JsoniterJavaParser.java

https://github.com/plokhotnyuk/jsoniter-scala/blob/master/jsoniter-scala-benchmark/src/main/java/com/jsoniter/output/JsoniterJavaSerializer.java

And it looks quite competitive vs DSL-JSON... Please, see results:

https://plokhotnyuk.github.io/jsoniter-scala/

plokhotnyuk avatar Dec 07 '18 15:12 plokhotnyuk