咖啡伴侣

呆在上海
posts - 163, comments - 156, trackbacks - 0, articles - 2

go对象序列化和反序列化

Posted on 2013-09-29 09:52 oathleo 阅读(3054) 评论(0)  编辑  收藏 所属分类: Golang
模拟测试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

只有注册用户登录后才能发表评论。


网站导航: