模拟测试1,000, 000条数据 每条10个字节 也就是10M不到的 数据(高度结构化的数据)
过程
1.对象序列化为 byte
2.byte反序为对象
3.gzip压缩byte
测试语言go
测试方案: raw byte,json ,bson, msgpack (protostuff需要先做对象配置文件,比较麻烦,通常认为和msgpack性能相当 )
结果:msgpack 胜出
大小
gzip压缩后大小
对象到byte耗时
byte到对象耗时
raw
10000000
6573252(65%)
未测试
未测试
json
47515988
7919511 (17%)
3248ms
5280ms
bson
49888910
9506965 (19%)
3863ms
6235ms
msgpack
29934223
7448484
2046ms
3113ms
raw data: 1000000
raw data gzip compress: 6573252 //gzip压缩后大小
start: 1000000
Marshal cost: 3248 //json 序列化耗时
json string: 47515988
json byte: 47515988 //二进制数组大小
Unmarshal cost: 5280 //json 反序列化耗时
test data: {1 100 0.9405091}
json gzip compress: 7919511 //gzip压缩后大小
start
Marshal cost: 3863
bson byte: 49888910
Unmarshal cost: 6235
test data: {1 100 0.9405091}
bson gzip compress: 9506965
start: 1000000
Marshal cost: 2046
msgpack: 29934223
Unmarshal cost: 3113
test data: {1 100 0.9405091}
msgpack gzip compress: 7448484
本文通过使用Go语言对10M高度结构化的数据进行序列化及反序列化操作,并采用gzip压缩,对比了rawbyte、json、bson及msgpack等不同格式的处理效率与资源消耗。
6167

被折叠的 条评论
为什么被折叠?



