Posted on 2013-09-29 09:52
oathleo 閱讀(3068)
評(píng)論(0) 編輯 收藏 所屬分類(lèi):
Golang
模擬測(cè)試1,000, 000條數(shù)據(jù) 每條10個(gè)字節(jié) 也就是10M不到的 數(shù)據(jù)(高度結(jié)構(gòu)化的數(shù)據(jù))
過(guò)程
1.對(duì)象序列化為 byte
2.byte反序?yàn)閷?duì)象
3.gzip壓縮byte
測(cè)試語(yǔ)言go
測(cè)試方案: raw byte,json ,bson, msgpack (protostuff需要先做對(duì)象配置文件,比較麻煩,通常認(rèn)為和msgpack性能相當(dāng) )
結(jié)果:msgpack 勝出
| 大小
| gzip壓縮后大小
| 對(duì)象到byte耗時(shí)
| byte到對(duì)象耗時(shí)
|
raw | 10000000
| 6573252(65%) | 未測(cè)試
| 未測(cè)試 |
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 序列化耗時(shí)
json string: 47515988
json byte: 47515988 //二進(jìn)制數(shù)組大小
Unmarshal cost: 5280 //json 反序列化耗時(shí)
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