Go
发布时间:2022-04-09 发布网站:大佬教程 code.js-code.com
大佬教程收集整理的这篇文章主要介绍了golang json 解析器哪家强?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_
874_0@全文@L_
262_0@:
https://github.com/json-iterator/go-benchmark
@H_
874_0@目的不是推销 json-iterator 。而是证明 json-iterator 不比其他的库更慢,从而使得大家可以把吐槽点放到其他方面:比如特性是不是齐全, api 是不是友好。重新发明 json 解析器
是因为经常需要处理奇怪格式的 json ,而又不想把数据转两遍。市面上没有 api 满足我的需求的,后面我会专门写一篇 api 介绍的
文章来演示 json-iterator 的独特性。(
https://github.com/json-itera... )
- @H_874_0@jsonparser:
https://github.com/buger/jsonparser
- @H_874_0@jsoniter pull-api:
https://github.com/json-iterator/go
- @H_874_0@jsoniter reflect-api:
https://github.com/json-iterator/go/blob/master/jsoniter_reflect.go
- @H_874_0@encoding/json: golang standard lib
- @H_874_0@easy json:
https://github.com/mailru/easyjson
@H_
874_0@测试设备
- @H_874_0@@L_489_5@: i7-6700K @ 4.0G
- @H_874_0@Level 1 cache size: 4 x 32 KB 8-way set associative instruction caches
- @H_874_0@Level 2 cache size: 4 x 256 KB 4-way set associative caches
- @H_874_0@Level 3 cache size: 8 Mb 16-way set associative shared cache
- @H_874_0@Go: 1.8beta1
small payload
@H_
874_0@
https://github.com/json-itera...
jsonparser |
jsoniter pull-api |
jsoniter reflect-api |
encoding/json |
easyjson |
599 ns/op |
515 ns/op |
684 ns/op |
2453 ns/op |
687 ns/op |
64 B/op |
64 B/op |
256 B/op |
864 B/op |
64 B/op |
2 allocs/op |
2 allocs/op |
4 allocs/op |
31 allocs/op |
2 allocs/op |
@H_
874_0@encoding/json 在 i7-6700K 上
性能还不错,但是在缓存小一些的 @L_
489_5@ 上
性能要比这慢更多。
@H_
874_0@
@H_454_56
@medium payload
jsonparser |
jsoniter pull-api |
jsoniter reflect-api |
encoding/json |
easyjson |
5238 ns/op |
4111 ns/op |
4708 ns/op |
24939 ns/op |
7361 ns/op |
104 B/op |
104 B/op |
368 B/op |
808 B/op |
248 B/op |
4 allocs/op |
4 allocs/op |
14 allocs/op |
18 allocs/op |
8 allocs/op |
@H_
874_0@
https://github.com/json-itera...
@H_
874_0@json-iterator 的反射 api 也是相当快的。
@H_
874_0@
large payload
@H_
874_0@
https://github.com/json-itera...
jsonparser |
jsoniter pull-api |
encoding/json |
38334 ns/op |
38463 ns/op |
290778 ns/op |
0 B/op |
0 B/op |
2128 B/op |
0 allocs/op |
0 allocs/op |
46 allocs/op |
@H_
874_0@jsonparser 在大部分字段不
使用的时候,要快那么一丁点。
@H_
874_0@
large file
@H_
874_0@test file used:
https://github.com/json-itera...
jsonparser |
jsoniter pull-api |
encoding/json |
42698634 ns/op |
37760014 ns/op |
235354502 ns/op |
67107104 B/op |
4248 B/op |
71467896 B/op |
19 allocs/op |
5 allocs/op |
272477 allocs/op |
@H_
874_0@jsonparser 等其他一大票 json 解析器都是以 []byte 作为输入的,简直是为跑分而生。关于这一点 jackson 的作者也有吐槽(
https://www.infoq.com/news/20... )。而 jsoniter 可以
支持 io.Reader 作为输入,对于大
文件处理非常友好。
@H_
874_0@
大佬总结
以上是大佬教程为你收集整理的golang json 解析器哪家强?全部内容,希望文章能够帮你解决golang json 解析器哪家强?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。