mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-08-11 02:23:42 +00:00
doc[protocol]: 性能测试文档
This commit is contained in:
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
@@ -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
|
||||
```
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
|
||||
### Ⅳ. 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接口返回的值一样
|
||||
|
||||
Reference in New Issue
Block a user