当前位置: 首页 > 工具软件 > Kryo > 使用案例 >

jackson、fastjson、kryo、protobuf等序列化效率对比【全】

盛城
2023-12-01

一、综合性能(序列化+反序列化+大小)

综合排名序列化方式
1kryo-manual
2protostuff-manual
3protostuff
4protobuf/protostuff
5java-manual
6wobly
7fst-flat-pre
8protostuff-runtime
9protobuf/protostuff-runtime
10wobly-compact
11protostuff-graph
12kryo-flat-pre
13protostuff-graph-runtime
14kryo-flat
15fst-flat
16protobuf
17kryo-opt
18json/fastjson/databind
19smile/jackson/manual
20scala/sbinary
21thrift-compact
22json/jackson/manual
23jboss-marshalling-river-ct-manual
24fst
25kryo-serializer
26msgpack-manual
27thrift
28cbor/jackson/manual
29msgpack-databind
30cbor/jackson/databind

二、序列化效率 

序列化效率排名序列化方式
1protostuff
2protostuff-manual
3protobuf/protostuff
4kryo-manual
5protostuff-runtime
6kryo-flat-pre
7fst-flat-pre
8protobuf/protostuff-runtime
9kryo-flat
10java-manual
11wobly
12protostuff-graph
13msgpack-manual
14protostuff-graph-runtime
15smile/jackson/manual
16wobly-compact
17fst-flat
18kryo-opt
19json/jackson/manual
20json/fastjson/databind
21msgpack-databind
22protobuf
23json/protostuff-manual
24cbor/jackson/databind
25cbor/jackson/manual
26smile/jackson/databind
27fst
28avro-specific
29json/jackson/databind
30scala/sbinary

三、反序列化效率 

反序列化效率排名序列化方式
1java-manual
2wobly
3kryo-manual
4fst-flat-pre
5protostuff-manual
6wobly-compact
7protobuf/protostuff
8protostuff
9protobuf/protostuff-runtime
10protostuff-runtime
11protostuff-graph
12protobuf
13protostuff-graph-runtime
14thrift-compact
15kryo-flat-pre
16kryo-flat
17fst-flat
18kryo-opt
19scala/sbinary
20json/fastjson/databind
21thrift
22jboss-marshalling-river-ct-manual
23kryo-serializer
24fst
25smile/jackson/manual
26json/jackson/manual
27msgpack-manual
28cbor/jackson/manual
29smile/jackson+afterburner/afterburner
30msgpack-databind

四、对象大小 

对象Size排名序列化方式
1kryo-opt
2kryo-manual
3kryo-flat-pre
4avro-generic
5avro-specific
6wobly-compact
7msgpack-databind
8msgpack-manual
9protobuf/protostuff
10protobuf
11protostuff-graph
12protostuff-manual
13protostuff
14thrift-compact
15protobuf/protostuff-runtime
16protostuff-graph-runtime
17protostuff-runtime
18fst-flat-pre
19wobly
20java-manual
21scala/sbinary
22kryo-flat
23kryo-serializer
24jboss-marshalling-river-ct-manual
25jboss-marshalling-river-ct
26fst-flat
27fst
28xml/exi-manual
29smile/jackson/databind
30smile/jackson/manual

五、总结 

Kryo——速度快,序列化后体积小;缺点是跨语言支持较复杂
Protostuff——速度快,基于protobuf;缺点是需静态编译
Protostuff-Runtime,无需静态编译,但序列化前需预先传入schema;缺点是不支持无默认构造函数的类,反序列化时需用户自己初始化序列化后的对象,其只负责将该对象进行赋值
Java——使用方便,可序列化所有类;缺点是速度慢,占空间

具体的对比可以参考这个基线图:

Results - JVM Serializer Benchmarks

 效率对比直观图:

An Introduction and Comparison of Several Common Java Serialization Frameworks - Alibaba Cloud Community

首选序列化:Kryo、Protostuff

 类似资料: