.NET Core protobuf-net、MessagePack、Json.NET序列化/反序列化性能测试
测试代码Zonciu/SerializationTest.cs,
源自neuecc/ZeroFormatterBenchmark.cs。
NuGet包及其版本
mgravell/protobuf-net 2.3.2(非官方实现,官方无.NET实现)
msgpack/msgpack-cli 1.0.0-beta2(官方实现)
neuecc/MessagePack 1.7.2(非官方实现)
JamesNK/Newtonsoft.Json 10.0.3
兼容性
protobuf-net
- 不支持无Contract Attribute的模型
- 自带Attribute
- 支持
System.Runtime.Serialization Attribute,
MsgPack-Cli
- 支持无Contract Attribute的模型
- 自带Attribute
- 支持
System.Runtime.Serialization Attribute
MessagePack
- 支持无Contract Attribute的模型
- 自带Attribute
- 支持
System.Runtime.Serialization Attribute
Newtonsoft.Json
- 支持无Contract Attribute的模型
- 自带Attribute
- 支持
System.Runtime.Serialization Attribute
测试结果
mgravell/protobuf-net
Serialize 4.195 ms
Deserialize 10.0423 ms
ReSerialize 4.1817 ms
Size of Binary 36.00 B
mgravell/protobuf-net
Serialize 4.172 ms
Deserialize 10.0139 ms
ReSerialize 4.1776 ms
Size of Binary 36.00 B
mgravell/protobuf-net
Serialize 4.4121 ms
Deserialize 10.2684 ms
ReSerialize 4.2439 ms
Size of Binary 36.00 B
Official MsgPack-Cli
Serialize 6.9675 ms
Deserialize 14.4727 ms
ReSerialize 6.7491 ms
Size of Binary 36.00 B
Official MsgPack-Cli
Serialize 6.7087 ms
Deserialize 14.4588 ms
ReSerialize 6.9524 ms
Size of Binary 36.00 B
Official MsgPack-Cli
Serialize 6.7676 ms
Deserialize 14.5932 ms
ReSerialize 6.9552 ms
Size of Binary 36.00 B
neuecc/MessagePack-CSharp
Serialize 3.703 ms
Deserialize 4.3366 ms
ReSerialize 3.6741 ms
Size of Binary 32.00 B
neuecc/MessagePack-CSharp
Serialize 3.7056 ms
Deserialize 4.6376 ms
ReSerialize 3.6672 ms
Size of Binary 32.00 B
neuecc/MessagePack-CSharp
Serialize 3.6871 ms
Deserialize 4.2972 ms
ReSerialize 3.6756 ms
Size of Binary 32.00 B
Newtonsoft.Json
Serialize 17.5037 ms
Deserialize 33.8181 ms
ReSerialize 21.2306 ms
Size of Binary 90.00 B
Newtonsoft.Json
Serialize 18.4885 ms
Deserialize 35.5003 ms
ReSerialize 17.4223 ms
Size of Binary 90.00 B
Newtonsoft.Json
Serialize 18.1058 ms
Deserialize 32.0834 ms
ReSerialize 23.5259 ms
Size of Binary 90.00 B
mgravell/protobuf-net
Serialize 6546.5884 ms
Deserialize 11488.7313 ms
ReSerialize 6709.2795 ms
Size of Binary 37.11 KB
mgravell/protobuf-net
Serialize 6564.3259 ms
Deserialize 11431.9974 ms
ReSerialize 6679.0116 ms
Size of Binary 37.11 KB
mgravell/protobuf-net
Serialize 6561.8096 ms
Deserialize 11476.1318 ms
ReSerialize 6668.9106 ms
Size of Binary 37.11 KB
Official MsgPack-Cli
Serialize 5617.6389 ms
Deserialize 14581.9512 ms
ReSerialize 5578.6621 ms
Size of Binary 38.82 KB
Official MsgPack-Cli
Serialize 5590.4476 ms
Deserialize 14763.014 ms
ReSerialize 5533.6327 ms
Size of Binary 38.82 KB
Official MsgPack-Cli
Serialize 5607.3836 ms
Deserialize 14615.2356 ms
ReSerialize 5585.7651 ms
Size of Binary 38.82 KB
neuecc/MessagePack-CSharp
Serialize 3065.3312 ms
Deserialize 4371.5859 ms
ReSerialize 3062.9087 ms
Size of Binary 32.83 KB
neuecc/MessagePack-CSharp
Serialize 3116.9423 ms
Deserialize 4392.1279 ms
ReSerialize 3061.0422 ms
Size of Binary 32.83 KB
neuecc/MessagePack-CSharp
Serialize 3080.5855 ms
Deserialize 4385.2026 ms
ReSerialize 3054.3972 ms
Size of Binary 32.83 KB
Newtonsoft.Json
Serialize 13303.1545 ms
Deserialize 24219.7497 ms
ReSerialize 13346.126 ms
Size of Binary 86.81 KB
Newtonsoft.Json
Serialize 13362.7296 ms
Deserialize 24238.1881 ms
ReSerialize 13332.8785 ms
Size of Binary 86.81 KB
Newtonsoft.Json
Serialize 13399.7856 ms
Deserialize 24197.9922 ms
ReSerialize 13325.7399 ms
Size of Binary 86.81 KB
neuecc/MessagePack-CSharp without Attribute
Serialize 3.9342 ms
Deserialize 4.9817 ms
ReSerialize 3.9434 ms
Size of Binary 65.00 B
neuecc/MessagePack-CSharp without Attribute
Serialize 3.9854 ms
Deserialize 4.9978 ms
ReSerialize 3.9498 ms
Size of Binary 65.00 B
neuecc/MessagePack-CSharp without Attribute
Serialize 3.9393 ms
Deserialize 5.1384 ms
ReSerialize 3.9293 ms
Size of Binary 65.00 B
neuecc/MessagePack-CSharp without Attribute
Serialize 3968.4564 ms
Deserialize 4912.953 ms
ReSerialize 4082.8229 ms
Size of Binary 65.06 KB
neuecc/MessagePack-CSharp without Attribute
Serialize 3967.5422 ms
Deserialize 4912.2183 ms
ReSerialize 4059.2614 ms
Size of Binary 65.06 KB
neuecc/MessagePack-CSharp without Attribute
Serialize 3952.6747 ms
Deserialize 4974.3738 ms
ReSerialize 4066.7528 ms
Size of Binary 65.06 KB
单对象序列化、反序列化、再序列化时间

多对象数组序列化、反序列化、再序列化时间

单对象序列化后数据大小

多对象数组序列化后数据大小

结论
neuecc/MessagePack表现最优,官方MsgPack-Cli表现比较差,Protobuf不支持无Contract Attribute模型,意味着需要侵入模型。
使用MessagePack,模型添加Contract Attribute并添加int型Order,比不添加Attribute或添加string型key快一点点,序列化后数据量明显减少,原因是不使用Attribute或使用string型Attribute key时,是以成员名称或key string作为索引,反之使用int型索引。
.NET Core protobuf-net、MessagePack、Json.NET序列化/反序列化性能测试的更多相关文章
- 二进制数据的序列化反序列化和Json的序列化反序列化的重要区别
前言:最近一个一个很奇怪的问题,很明白的说,就是没看懂,参照下面的代码: /// <summary> /// 反序列化对象 /// </summary> /// <typ ...
- 项目收集-AutoMapper使用,事务,Json.Net序列化反序列化,代码生成调用等
using System; using AutoMapper; using Newtonsoft.Json; using Newtonsoft.Json.Linq; namespace Console ...
- 05-06 Flutter JSON和序列化反序列化、创建模型类转换Json数据、轮播图数据渲染:Flutter创建商品数据模型 、请求Api接口渲染热门商品 推荐商品
Config.dart class Config{ static String domain='http://jd.itying.com/'; } FocusModel.dart class Focu ...
- Newtonsoft.Json.Linq 序列化 反序列化等知识
1.反序列化实体类 //使用JObject读写字符串:JObject j = JObject.Parse(data);IEnumerable<JProperty> properties = ...
- php json与xml序列化/反序列化
在web开发中对象的序列化与反序列化经常使用,比较主流的有json格式与xml格式的序列化与反序列化,今天想写个jsop的小demo,结果发现不会使用php序列化,查了一下资料,做个笔记 简单数组js ...
- 基于.NET CORE微服务框架 -谈谈surging 的messagepack、protobuffer、json.net 序列化
1.前言 surging内部使用的是高性能RPC远程服务调用,如果用json.net序列化肯定性能上达不到最优,所以后面扩展了protobuf,messagepack序列化组件,以支持RPC二进制传输 ...
- 在Asp.Net Core 3.0中如何使用 Newtonsoft.Json 库序列化数据
在.Net Core 3.0中 内置了一套Json序列化/反序列化方案,默认可以不再依赖,不再支持 Newtonsoft.Json. 但是.NET Core 3.0 System.Text.Jso ...
- 序列化 反序列化 MessagePack for C#
阅读目录 快速序列化组件MessagePack介绍 简介 使用 快速开始 分析器 内置的支持类型 对象序列化 DataContract兼容性 序列化不可变对象(序列化构造器) 序列化回调 Union ...
- 超越 JSON: Spearal 序列化协议简介
Spearal 是一个新的开源的序列化协议,这个协议旨在初步替换JSON 将HTML和移动应用连接到Java的后端. Spearal的主要目的是提供一个序列协议,这个协议即使是在端点间传输的复杂的 ...
随机推荐
- jar文件内lib引用的jar插件修改后更新
打包的java服务在第三方jar进行修改后,要更新线上的jar包时,直接替换原有lib引用的jar文件,会造成服务起不来, 可在本地clean install之后,用线上的classes文件夹替换本地 ...
- iOS开发之图片压缩实现
使用下面两个方法,先按尺寸重绘图片,然后再降低品质上传图片data #pragma mark 裁剪照片 -(UIImage *)scaleToSize:(UIImage *)image size:(C ...
- 输出九九乘法表(Python、Java、C、C++、JavaScript)
最近在学python的过程中,接触到了循环的知识,以及这个案例,于是写了下!感觉还不错,然后就用其它几种语言也试了下!! 接下来,就跟大家分享下实现方法!! 实现输出九九乘法表,主要用到的是循环的知识 ...
- Mysql更新关联子查询报错
报错内容:sql 1093 - You can't specify target table 'u' for update in FROM clause 错误原因: if you're doing ...
- hadoop fs -put 报错
[hadoop@master ~]$ ll total -rw-rw-r-- hadoop hadoop Apr : aaa drwxr-xr-x hadoop hadoop Jun Desktop ...
- TortoiseGit的ssh key和Git的ssh key
情景模拟: 你使用Git+TortoiseGit对项目进行版本控制,本地库(自己电脑建立的.git)与远程库(如GitLab上建立)通信需要使用ssh验证,你用git生成公钥并保存到了Gitlab上, ...
- centos7搭建zabbix3.0监控系统
关闭防火墙和selinux systemctl stop firewalld.service (停止防火墙) systemctl disable firewalld.se ...
- Django——小结
课程介绍 MVC MVC框架的核心思想是:解耦,让不同的代码块之间降低耦合,增强代码的可扩展性和可移植性,实现向后兼容 M:Model,主要封装对数据库层的访问,对数据库中的数据进行增.删.改.查操作 ...
- [LeetCode] Keys and Rooms 钥匙与房间
There are N rooms and you start in room 0. Each room has a distinct number in 0, 1, 2, ..., N-1, an ...
- Katalon Studio之接口测试中token处理
前言 最近抽时间接触了一下Katalon Studio(后面简称KS),并且利用KS做了一些接口测试的试验,感觉还不错,不过其中接口授权中缺少通过token动态验证的方案,虽然KS支持Authoriz ...