4 ms·
Unlike other implementations, as far as I can tell, this one composes encoders. Under the hood it can use encoding/json.Marshal or goccy/go-json.Marshal (anothe
by eatonphil 5y ago
Unlike other implementations, as far as I can tell, this one composes encoders. Under the hood it can use encoding/json.Marshal or goccy/go-json.Marshal (another existing very fast library) or any other libary that implements the json.Marshal call.
This implementation is competitive (sometimes faster, sometimes slower) with good implementations like goccy/go-json on its own, and beats goccy/go-json when composing this library with goccy/go-json.
This composition and goccy/go-json performance is included in the post.
Maybe in a followup post I'll do more benchmarks against other fast libraries. But for this one I wanted to show the process and then just pick one fast library for comparison.
Edit: also, I forgot to mention in the post but some libraries speed up encoding by requiring a fixed schema. DataStation/dsq is extremely dynamic and I'll never know the schema up front. Just another reason why I couldn't use some existing faster libraries.
- latchkey 5y agoAll I am saying is that the 'fastest' json libs all do comparisons against other 'fastest' json libs. I'd expect any other json lib trying to be faster to do those same comparisons and not produce arguably clickbait "55% faster" titles since your library isn't really that much faster than goccy. Pick the ones that match (dynamic) to compare against.
- eatonphil 5y agoIf you're not a fan of the blog post that's cool. But I posted the blog post (and wrote the post in the first place) rather than a Show HN link to the project itself because I thought the process was worth showing as much as the result.
- mh- 5y ago> I thought the process was worth showing as much as the result it was, thanks for sharing.
- strangeattractr 5y agoI enjoyed reading it, as someone who writes a lot of go but hasn't done any profiling of code.
- kodah 5y agoI've known for some time that the JSON process of marshaling is expensive in Go; this post illuminates why and taught me how to test these kinds of things myself. It's excellent and I appreciate you sharing your methodology.