标签:
本文目的是比较这四个方法的优缺点,并给出解决方案。
library | function interface | input/ output parameter | note | |
sproto |
1.en=cookie.encode(ab)
2.de=cookie.decode(en)
|
1. input: ab is table
2. input: en is binary string
|
1. the schema of the sproto is very strong and flexible
2. 编写proto文件非常简单而且很人性化
3. 使用简单易用
|
|
sproto(nopack) | similar with sproto | similar with sproto | ||
pbc-lua |
|
1. input: CookieValue is table,
2. input en is binary
|
这个decode出来的table是惰性展开的,访问该table时才能解开,不然会出现乱码 | |
protobuf-c++ |
|
1. input: tb is a table,
2.input: str is binary string
|
1. 一有改动,较难维护
2. 耗费时间多小与压缩比效果很好,比其他的方法
|
|
lua-cjson |
1. en=cjson.encode(tb)
2.de=cjson.decode(en)
|
1. input: tb is a table,
2. input: en is cjson string
|
1. 空间占用很大
2. 耗费时间过大
3. 优点:(对我们现有的使用来看)无须转换程序,即解即用
|
library | encode times(1M次) | decode times(1M次) | size(byets) |
sproto | 4.6501181125641s | 11.385328769684s | 139 |
sproto(nopack) | 4.0319328308105s | 9.9806959629059s | 272 |
pbc-lua | 9.3938179016113s | 7.0795350074768s | 117 |
protobuf-c++ | 6.0948710441589s | 9.6896359920502s | 117 |
lua-cjson | 23.541377067566s | 15.335454940796s | 437 |
测 试数据:{"pbid":[{"id":100188,"value":3},{"id":100189,"value":3}, {"id":100190,"value":3}],"daily":[{"daily_id":1125,"date_id":[{"id":100188,"value":1}]},{"daily_id":1126,"date_id":[{"id":100118,"value":1}]}],"total":[{"id":100188,"value":1}],"segments":[{"type":1,"ct":1415384160,"ttl":1415384160,"id":100001}],"imp":[{"win":2,"bid":3,"time":8160,"id":100188},{"win":2,"bid":3,"time":8155,"id":100182},{"win":2,"bid":3,"time":8157,"id":100181}]}
json, protobuf-c++,pbc,sproto 性能测试与解决方案
标签:
原文地址:http://www.cnblogs.com/xavierxia/p/4598504.html