doc[protocol]: 性能测试文档

This commit is contained in:
jaysunxiao
2021-05-26 08:05:57 +08:00
parent bca8b9f7b7
commit 6fa93ec2a5
7 changed files with 22 additions and 8 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

+22 -8
View File
@@ -1,15 +1,13 @@
### 1. 简介
### . 简介
- zfoo protocol是目前的Java二进制序列化和反序列化最快的框架,协议跨平台支持Java Javascript C# Lua,并且线程安全
- 主要是用Javassist字节码增强动态生成顺序执行的序列化和反序列化函数,顺序执行的函数可以轻易的被JIT编译以达到极致的性能
- 单线程环境,在没有任何JVM参数调优的情况下速度比Kryo快40%,比Protobuf快110%[参见性能测试](src/test/java/com/zfoo/protocol/SpeedTest.java)
- 多线程环境,zfoo和Protobuf的性能不受任何影响,kryo因为线程不安全性能会有所损失,[参见性能测试](src/test/java/com/zfoo/protocol/SpeedTest.java)
### 2. 环境要求
### . 快速使用
**JDK 11+**,可以在 **OpenJDK****Oracle JDK** 无缝切换
### 3. 快速使用
- 环境要求 **JDK 11+**,可以在 **OpenJDK****Oracle JDK** 无缝切换
```
// zfoo协议注册,只能初始化一次
@@ -22,7 +20,23 @@ ProtocolManager.write(byteBuf, complexObject);
var packet = ProtocolManager.read(buffer);
```
### 4. zfoo的优势
### . 性能测试
- 下面的是测试环境,横坐标为序列化和发序列化的对象数量,纵坐标为花费的时间毫秒
```
操作系统:win10
cpu i9900k
主板:华硕z390
内存:64g
```
![Image text](../event/tooltip/protocol/simple_object.png)
![Image text](../event/tooltip/protocol/simple_data.jpg)
![Image text](../event/tooltip/protocol/normal_object.png)
![Image text](../event/tooltip/protocol/normal_data.jpg)
![Image text](../event/tooltip/protocol/complex_object.png)
![Image text](../event/tooltip/protocol/complex_data.jpg)
### Ⅳ. zfoo的优势
- 没有反射,没有装箱拆箱
- 天生线程安全;对比kryo会出现性能损耗
@@ -34,11 +48,11 @@ var packet = ProtocolManager.read(buffer);
- 智能语法分析,错误的协议定义将无法启动程序并给出错误警告
- 提升开发效率,完全支持POJO方式开发,使用非常简单
### 5. 待解决的问题
### . 待解决的问题
- 为了代码的优雅,zfoo protocol要求全部的协议都要继承IPacket,但是可以保证不损失性能的情况下支持不继承IPacket的设计,这个有待继续讨论。
### 6. 协议规范
### . 协议规范
- 协议类必须实现com.zfoo.protocol.model.packet.IPacket接口,协议类的的protocolId不能重复
- 协议类必须有一个标识为:public static final transient short PROTOCOL_ID的"协议序列号",这个协议号的值必须和IPacket接口返回的值一样