ego008 avatar

go 终于有一个快一点的JSON 库出来了 easyjson

🕦 by ego008

easyjson

easyjson vs. encoding/json

1
easyjson seems to be 5-6 times faster than the default json serialization for unmarshalling, 3-4 times faster for non-concurrent marshalling. Concurrent marshalling is 6-7x faster if marshalling to a writer.

easyjson vs. ffjson

1
2
3
4
5
easyjson uses the same approach for code generation as ffjson, but a significantly different approach to lexing and generated code. This allows easyjson to be 2-3x faster for unmarshalling and 1.5-2x faster for non-concurrent unmarshalling.

ffjson seems to behave weird if used concurrently: for large request pooling hurts performance instead of boosting it, it also does not quite scale well. These issues are likely to be fixable and until that comparisons might vary from version to version a lot.

easyjson is similar in performance for small requests and 2-5x times faster for large ones if used with a writer.

easyjson vs 'ujson' python module

1
2
3
ujson is using C code for parsing, so it is interesting to see how plain golang compares to that. It is imporant to note that the resulting object for python is slower to access, since the library parses JSON object into dictionaries.

easyjson seems to be slightly faster for unmarshalling (finally!) and 2-3x faster for marshalling.

https://github.com/mailru/easyjson

💘 相关文章

评论

共1条关于"go 终于有一个快一点的JSON 库出来了 easyjson"的评论

写一条评论

Based on Golang + fastHTTP + sdb | go1.16.5 Processed in 1ms