Avro与Protobuf性能对比
所用Schema
Avro所用Schema
{"namespace": "test.avro",
"type": "record",
"name": "User",
"fields": [
{"name": "i", "type": ["int","null"]},
{"name": "l", "type": ["long", "null"]},
{"name": "s", "type": ["string", "null"]},
{"name":"b","type":["boolean","null"]}
]
}
Protobuf所用Schema
message SomeData {
optional int32 i = 1;
optional int64 l = 2;
optional string s = 3;
optional bool b=4;
}
写出的数据:
{
"i" : random,
"l" : random,
"s" : "never",
"b" : random
}
测试对象:
- 用
protoc</

本文对比了Avro与Protobuf在性能上的差异,包括生成文件和序列化但不生成文件两个测试场景。测试结果显示,Protobuf在速度上比Avro快2~4倍。Avro在不生成文件时表现更慢,可能与其处理方式有关,而Protobuf的不同接入方法也影响了效率。
最低0.47元/天 解锁文章
900

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



