diff --git a/event/tooltip/protocol/complex_data.jpg b/event/tooltip/protocol/complex_data.jpg new file mode 100644 index 00000000..2a078834 Binary files /dev/null and b/event/tooltip/protocol/complex_data.jpg differ diff --git a/event/tooltip/protocol/complex_object.png b/event/tooltip/protocol/complex_object.png new file mode 100644 index 00000000..1f0aad19 Binary files /dev/null and b/event/tooltip/protocol/complex_object.png differ diff --git a/event/tooltip/protocol/normal_data.jpg b/event/tooltip/protocol/normal_data.jpg new file mode 100644 index 00000000..b536d085 Binary files /dev/null and b/event/tooltip/protocol/normal_data.jpg differ diff --git a/event/tooltip/protocol/normal_object.png b/event/tooltip/protocol/normal_object.png new file mode 100644 index 00000000..f23f3c3b Binary files /dev/null and b/event/tooltip/protocol/normal_object.png differ diff --git a/event/tooltip/protocol/simple_data.jpg b/event/tooltip/protocol/simple_data.jpg new file mode 100644 index 00000000..752897fd Binary files /dev/null and b/event/tooltip/protocol/simple_data.jpg differ diff --git a/event/tooltip/protocol/simple_object.png b/event/tooltip/protocol/simple_object.png new file mode 100644 index 00000000..a4c616e1 Binary files /dev/null and b/event/tooltip/protocol/simple_object.png differ diff --git a/protocol/README.md b/protocol/README.md index 58392ffb..2cea4d45 100644 --- a/protocol/README.md +++ b/protocol/README.md @@ -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接口返回的值一样