You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've written a benchmark to compare MessagePack, stdlib Json, Sonic Json and Protobuf to decide on a codec for a project, but I'm consistently getting unexpected results for Sonic vs. Go Json.
The decoding is faster than stdlib, just as expected. Advertised is 3,2x faster, I'm getting 3,2x faster, up to 3,9x faster.
But the encoding is weirdly slow. Go Json is 2x faster than sonic.
I thought it might be because the objects aren't really that complex, but the README says that:
For all sizes of json and all scenarios of usage, Sonic performs best.
So I would have thought that includes my scenario as well.
For the single benchmark I'm en/decoding the following item:
The multiple one is using an type Items []Item with similar values to the item above.
Here are the benchmark results (along with the proto and msgpack ones)
bytes/obj is a metric I added to compare the resulting size.
Just to rule out the issue is with my setup, my struct or my code, I've also added Go Json and Json Iterator to the benchmark, as in Sonic' README.
If needed, I can add the benchmark code, but it's the exact same function for all (expect proto for obvious reasons), just with the respective (Un)Marshal function passed in, so basically encode(b, sonic.Marshal), etc.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I've written a benchmark to compare MessagePack, stdlib Json, Sonic Json and Protobuf to decide on a codec for a project, but I'm consistently getting unexpected results for Sonic vs. Go Json.
The decoding is faster than stdlib, just as expected. Advertised is 3,2x faster, I'm getting 3,2x faster, up to 3,9x faster.
But the encoding is weirdly slow. Go Json is 2x faster than sonic.
I thought it might be because the objects aren't really that complex, but the README says that:
So I would have thought that includes my scenario as well.
For the single benchmark I'm en/decoding the following item:
The multiple one is using an
type Items []Item
with similar values to the item above.Here are the benchmark results (along with the proto and msgpack ones)
bytes/obj
is a metric I added to compare the resulting size.Just to rule out the issue is with my setup, my struct or my code, I've also added Go Json and Json Iterator to the benchmark, as in Sonic' README.
If needed, I can add the benchmark code, but it's the exact same function for all (expect proto for obvious reasons), just with the respective (Un)Marshal function passed in, so basically
encode(b, sonic.Marshal)
, etc.Does anyone has an idea why the encoding is so much faster in the stdlib Json, instead of Sonic like how I expected it to be?
Beta Was this translation helpful? Give feedback.
All reactions