.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的主要目的是提供一个序列协议,这个协议即使是在端点间传输的复杂的 ...
随机推荐
- .Karma+Jasmine+karma-coverage
单元测试(模块测试)是开发者编写的一小段代码,用于检验被测代码的一个很小的.很明确的功能是否正确.通常而言,一个单元测试是用于判断某个特定条件(或者场景)下某个特定函数的行为. Karma是一个基于N ...
- js == 运算规则解析
1.先了解一下基本类型和复杂类型划分的依据 JS中的值有两种类型:原始类型(Primitive).对象类型(Object).原始类型包括:Undefined.Null.Boolean.Number和S ...
- Java课程之团队开发(NABCD需求分析)
N.需求 1.学生基本的录入课程功能 2.学生对于空教室使用的需求(自习或者是活动占用) 3.学生对于具体课程的查询需求 A.做法 1.制作出基于安卓的课程查询,录入以及教室查询应用软件 B.好处 1 ...
- thinkphp 找数据库某个字段为空的数据,PHP 数据调取 空数据
$arr['dingwei'] = array('EXP','is null');
- IIS中 flv、swf 文件无法播放
解决方案: 1.服务器安装flash,这是必须的. 2.MIME类型添加两个:名称.swf,值application/x-shockwave-flash:名称.flv,值flv-application ...
- JS加密对应的c#解码
escape不编码字符有69个:*,+,-,.,/,@,_,0-9,a-z,A-Z encodeURI不编码字符有82个:!,#,$,&,',(,),*,+,,,-,.,/,:,;,=,? ...
- 【DFS】困难的串
题目: 问题描述:如果一个字符串包含两个相邻的重复子串,则称它为容易的串,其他串称为困难的串.如:BB,ABCDACABCAB,ABCDABCD都是容易的,A,AB,ABA,D,DC,ABDAB,CB ...
- PHP_DOC php文档结构及注解浏览
项目中的PHP文件比较多,为了方便查看,使用PHP写了个小工具,可查看PHP文件的所有类.函数 和特定注释. 显示PHP文件的 Class 和 Function 显示 /// 开头的注解 显示 /// ...
- 一个完整的 Web 请求到底发生了什么
阅读本文大概需要 7 分钟. 一.从输入一个网址开始 当我们在浏览器输入一个网址,然后按下回车,接下来浏览器显示了页面.网速好的话这之间可能就一秒,但在这一秒内到底发生了什么? 本文主要内容是试图记录 ...
- ubuntu系统界面改变
主题:https://gitzab.com/Anduin/GNOME-OSX-II-Theme.git图标:https://github.com/keeferrourke/la-capitaine-i ...