RealTimeChris / Json-Performance

A few C++ json-library benchmarks, of the fastest few libraries.
MIT License
20 stars 2 forks source link

Prettified write performance? #5

Closed stephenberry closed 6 months ago

stephenberry commented 7 months ago

Prettified write performance in the benchmarks doesn't make sense to me, because it doesn't actually seem to be writing prettified data.

Glaze has built in support to write prettified data, but I don't think Jsonifier can. Jsonifier could call its prettify method after calling write, but this would be two steps and probably much slower.

RealTimeChris commented 7 months ago

Do you mean to say that it's not serializing json in the process of prettifying? I thought that's what was meant by prettifying json data - going from a string of minified json data to a string of prettified json data, which is also what is being done with glaze in the benchmarks - is it not?

stephenberry commented 7 months ago

The benchmarks do test glz::prettify_json on a string buffer. But, often a user will want to generate prettified JSON directly from the C++ objects, just like how we read JSON directly into C++ objects. Glaze offers glz::write<glz::opts{.prettify = true}>(obj, buffer); , which will directly convert the C++ object into prettified JSON.

Right now your tests using objects under ... (Prettified) Results don't actually write out prettified JSON. They write out minified JSON.

RealTimeChris commented 7 months ago

What is meant by "Prettified" is that the input json data is prettified.

stephenberry commented 7 months ago

Right, but you're just doing two of the same tests when you could also be testing the prettified write performance.

RealTimeChris commented 6 months ago

Alright thanks. I've updated Jsonifier to be able to directly write as prettified data as well as modified the benchmarks to reflect this as well as set it up so that glaze would also be tested in the same way.

stephenberry commented 6 months ago

Awesome! Thanks!