ngs-doo / json-benchmark

JSON benchmark for .NET and Java
Other
72 stars 6 forks source link

Benchmark improvement #7

Open paya-cz opened 6 years ago

paya-cz commented 6 years ago

Seems to me like you are running the benchmarks without first JITting the libraries/benchmark code. I recommend running a throwaway repeat=1 RunLoop over all your factory methods before running the real benchmark. Gives you a lot more accurate results, as JIT time or library initialization time should not really be a factor.

Anyway seems like Revenj managed to beat Jil. Did you have to cut corners and you may not be able to parse all "exotic" jsons, handle encodings/escaping etc?

zapov commented 6 years ago

It's done like that on purpose to include startup overhead, which can be quite a different for different libraries. Revenj for example, does analysis during compilation, so it's only the JIT compilation, not the type analysis. Also, on mobile it's quite common to only do a single processing without any warmup, so the most common server scenarios are not the only relevant scenarios.

Well, 4 years ago when this was built Revenj did a lot more than others (with the exception of Newtonsoft) and it was the only one which didn't fail on even "standard" types. I did not improve it much since then, so it doesn't do runtime analysis - it falls back to other library in that case. I did improve Java version... which now even has runtime analysis part built in.

So there was not really cutting corners, just avoiding GC, working on low levels and writing custom type encoders instead of relying on String conversion or built in ones.