test[protocol]add performance test of specific object

This commit is contained in:
aoyu
2023-02-27 12:04:36 +08:00
parent 1c32a576a0
commit e06e2d1aa8
10 changed files with 12594 additions and 22 deletions
@@ -3,13 +3,12 @@ package com.zfoo.protocol.field;
import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import com.google.protobuf.ByteString;
import com.google.protobuf.CodedInputStream;
import com.google.protobuf.CodedOutputStream;
import com.zfoo.protocol.ProtocolManager;
import com.zfoo.protocol.field.packet.FieldProtobufObject;
import com.zfoo.protocol.field.packet.FloatObject;
import com.zfoo.protocol.field.packet.IntObject;
import com.zfoo.protocol.field.packet.IntegerObject;
import com.zfoo.protocol.collection.ArrayUtils;
import com.zfoo.protocol.field.packet.*;
import com.zfoo.protocol.generate.GenerateOperation;
import com.zfoo.protocol.util.StringUtils;
import io.netty.buffer.ByteBuf;
@@ -20,10 +19,7 @@ import org.junit.Ignore;
import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import java.util.*;
/**
* 测试各种不同特征的数据类型的序列化和反序列化时间
@@ -35,14 +31,28 @@ public class FieldSpeedTest {
public static IntObject intObject=new IntObject();
public static IntegerObject integerObject=new IntegerObject();
public static FloatObject floatObject=new FloatObject();
public static BytesObject bytesObject=new BytesObject();
public static StringObject stringObject=new StringObject();
public static ListIntegerObject listIntegerObject=new ListIntegerObject();
public static SetObject setObject=new SetObject();
public static MapObject mapObject=new MapObject();
public static InnerObjectObject innerObjectObject=new InnerObjectObject();
public static FieldProtobufObject.IntObject protobufIntObject = null;
public static FieldProtobufObject.FloatObject protobufFloatObject = null;
public static FieldProtobufObject.BytesObject protobufBytesObject = null;
public static FieldProtobufObject.StringObject protobufStringObject = null;
public static FieldProtobufObject.ListIntegerObject protobufListIntegerObject=null;
public static FieldProtobufObject.MapObject protobufMapObject=null;
public static FieldProtobufObject.InnerObjectObject protobufInnerObjectObject=null;
public static long zfooSerializationTime;
public static long zfooDeserializationTime;
public static long kryoSerializationTime;
public static long kryoDeserializationTime;
public static long protobufSerializationTime;
public static long protobufDeserializationTime;
public static long zfooSerializationSize;
public static long kryoSerializationSize;
public static long protobufSerializationSize;
@Test
public void testIntObject() throws IOException {
ByteBuf buffer = new UnpooledHeapByteBuf(ByteBufAllocator.DEFAULT, 10000_0000, 100000000);
@@ -53,6 +63,7 @@ public class FieldSpeedTest {
ProtocolManager.write(buffer,intObject);
}
zfooSerializationTime=System.currentTimeMillis() - startTime;
zfooSerializationSize=buffer.writerIndex();
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
@@ -69,6 +80,7 @@ public class FieldSpeedTest {
kryo.writeObject(output, intObject);
}
kryoSerializationTime=System.currentTimeMillis() - startTime;
kryoSerializationSize=output.position();
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
@@ -85,6 +97,7 @@ public class FieldSpeedTest {
}
protobufSerializationTime=System.currentTimeMillis() - startTime;
var length=codedOutputStream.getTotalBytesWritten();
protobufSerializationSize=length;
var singleLength = length/benchmark;
var l=0;
//在循环中去掉创建CodedInputStream的代码,保证比较耗时公平性
@@ -99,9 +112,9 @@ public class FieldSpeedTest {
var mess = FieldProtobufObject.IntObject.parseFrom(codeInputs[i]);
}
protobufDeserializationTime=System.currentTimeMillis() - startTime;
System.out.println(StringUtils.format("序列化 [zfoo] [int类型] [thread:{}] [time:{}]", Thread.currentThread().getName(), zfooSerializationTime));
System.out.println(StringUtils.format("序列化 [kryo] [int类型] [thread:{}] [time:{}]", Thread.currentThread().getName(), kryoSerializationTime));
System.out.println(StringUtils.format("序列化 [protobuf] [int类型] [thread:{}] [time:{}]", Thread.currentThread().getName(),protobufSerializationTime));
System.out.println(StringUtils.format("序列化 [zfoo] [int类型] [thread:{}] [time:{}] [size:{}]", Thread.currentThread().getName(), zfooSerializationTime,zfooSerializationSize));
System.out.println(StringUtils.format("序列化 [kryo] [int类型] [thread:{}] [time:{}] [size:{}]", Thread.currentThread().getName(), kryoSerializationTime,kryoSerializationSize));
System.out.println(StringUtils.format("序列化 [protobuf] [int类型] [thread:{}] [time:{}] [size:{}]", Thread.currentThread().getName(),protobufSerializationTime,protobufSerializationSize));
System.out.println(StringUtils.format("反序列化 [zfoo] [int类型] [thread:{}] [time:{}]", Thread.currentThread().getName(), zfooDeserializationTime));
System.out.println(StringUtils.format("反序列化 [kryo] [int类型] [thread:{}] [time:{}]", Thread.currentThread().getName(),kryoDeserializationTime));
System.out.println(StringUtils.format("反序列化 [protobuf] [int类型] [thread:{}] [time:{}]", Thread.currentThread().getName(), protobufDeserializationTime));
@@ -117,6 +130,7 @@ public class FieldSpeedTest {
ProtocolManager.write(buffer,integerObject);
}
zfooSerializationTime=System.currentTimeMillis() - startTime;
zfooSerializationSize=buffer.writerIndex();
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
@@ -133,6 +147,7 @@ public class FieldSpeedTest {
kryo.writeObject(output, integerObject);
}
kryoSerializationTime=System.currentTimeMillis() - startTime;
kryoSerializationSize=output.position();
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
@@ -149,6 +164,7 @@ public class FieldSpeedTest {
}
protobufSerializationTime=System.currentTimeMillis() - startTime;
var length=codedOutputStream.getTotalBytesWritten();
protobufSerializationSize=length;
var singleLength = length/benchmark;
var l=0;
//在循环中去掉创建CodedInputStream的代码,保证比较耗时公平性
@@ -163,9 +179,9 @@ public class FieldSpeedTest {
var mess = FieldProtobufObject.IntObject.parseFrom(codeInputs[i]);
}
protobufDeserializationTime=System.currentTimeMillis() - startTime;
System.out.println(StringUtils.format("序列化 [zfoo] [Integer类型] [thread:{}] [time:{}]", Thread.currentThread().getName(), zfooSerializationTime));
System.out.println(StringUtils.format("序列化 [kryo] [Integer类型] [thread:{}] [time:{}]", Thread.currentThread().getName(), kryoSerializationTime));
System.out.println(StringUtils.format("序列化 [protobuf] [int类型] [thread:{}] [time:{}]", Thread.currentThread().getName(),protobufSerializationTime));
System.out.println(StringUtils.format("序列化 [zfoo] [Integer类型] [thread:{}] [time:{}] [size:{}]", Thread.currentThread().getName(), zfooSerializationTime,zfooSerializationSize));
System.out.println(StringUtils.format("序列化 [kryo] [Integer类型] [thread:{}] [time:{}] [size:{}]", Thread.currentThread().getName(), kryoSerializationTime,kryoSerializationSize));
System.out.println(StringUtils.format("序列化 [protobuf] [int类型] [thread:{}] [time:{}] [size:{}]", Thread.currentThread().getName(),protobufSerializationTime,protobufSerializationSize));
System.out.println(StringUtils.format("反序列化 [zfoo] [Integer类型] [thread:{}] [time:{}]", Thread.currentThread().getName(), zfooDeserializationTime));
System.out.println(StringUtils.format("反序列化 [kryo] [Integer类型] [thread:{}] [time:{}]", Thread.currentThread().getName(),kryoDeserializationTime));
System.out.println(StringUtils.format("反序列化 [protobuf] [int类型] [thread:{}] [time:{}]", Thread.currentThread().getName(), protobufDeserializationTime));
@@ -181,6 +197,7 @@ public class FieldSpeedTest {
ProtocolManager.write(buffer,floatObject);
}
zfooSerializationTime=System.currentTimeMillis() - startTime;
zfooSerializationSize=buffer.writerIndex();
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
@@ -197,6 +214,7 @@ public class FieldSpeedTest {
kryo.writeObject(output, floatObject);
}
kryoSerializationTime=System.currentTimeMillis() - startTime;
kryoSerializationSize=output.position();
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
@@ -213,6 +231,7 @@ public class FieldSpeedTest {
}
protobufSerializationTime=System.currentTimeMillis() - startTime;
var length=codedOutputStream.getTotalBytesWritten();
protobufSerializationSize=length;
var singleLength = length/benchmark;
var l=0;
//在循环中去掉创建CodedInputStream的代码,保证比较耗时公平性
@@ -227,13 +246,387 @@ public class FieldSpeedTest {
var mess = FieldProtobufObject.FloatObject.parseFrom(codeInputs[i]);
}
protobufDeserializationTime=System.currentTimeMillis() - startTime;
System.out.println(StringUtils.format("序列化 [zfoo] [float类型] [thread:{}] [time:{}]", Thread.currentThread().getName(), zfooSerializationTime));
System.out.println(StringUtils.format("序列化 [kryo] [float类型] [thread:{}] [time:{}]", Thread.currentThread().getName(), kryoSerializationTime));
System.out.println(StringUtils.format("序列化 [protobuf] [float类型] [thread:{}] [time:{}]", Thread.currentThread().getName(),protobufSerializationTime));
System.out.println(StringUtils.format("序列化 [zfoo] [float类型] [thread:{}] [time:{}] [size:{}]", Thread.currentThread().getName(), zfooSerializationTime,zfooSerializationSize));
System.out.println(StringUtils.format("序列化 [kryo] [float类型] [thread:{}] [time:{}] [size:{}]", Thread.currentThread().getName(), kryoSerializationTime,kryoSerializationSize));
System.out.println(StringUtils.format("序列化 [protobuf] [float类型] [thread:{}] [time:{}] [size:{}]", Thread.currentThread().getName(),protobufSerializationTime,protobufSerializationSize));
System.out.println(StringUtils.format("反序列化 [zfoo] [float类型] [thread:{}] [time:{}]", Thread.currentThread().getName(), zfooDeserializationTime));
System.out.println(StringUtils.format("反序列化 [kryo] [float类型] [thread:{}] [time:{}]", Thread.currentThread().getName(),kryoDeserializationTime));
System.out.println(StringUtils.format("反序列化 [protobuf] [float类型] [thread:{}] [time:{}]", Thread.currentThread().getName(), protobufDeserializationTime));
}
@Test
public void testBytesObject() throws IOException {
ByteBuf buffer = new UnpooledHeapByteBuf(ByteBufAllocator.DEFAULT, 10000_0000, 100000000);
benchmark=benchmark*5;
long startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
ProtocolManager.write(buffer,bytesObject);
}
zfooSerializationTime=System.currentTimeMillis() - startTime;
zfooSerializationSize=buffer.writerIndex();
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
var packet = ProtocolManager.read(buffer);
}
zfooDeserializationTime=System.currentTimeMillis() - startTime;
buffer.release();
var kryo = kryos.get();
var output = new Output(10000_0000);
var input = new Input(output.getBuffer());
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
kryo.writeObject(output, bytesObject);
}
kryoSerializationTime=System.currentTimeMillis() - startTime;
kryoSerializationSize=output.position();
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
var mess = kryo.readObject(input,BytesObject.class);
}
kryoDeserializationTime=System.currentTimeMillis() - startTime;
output.close();
var protobufBuff=new byte[10000_0000];
var codedOutputStream = CodedOutputStream.newInstance(protobufBuff);
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
protobufBytesObject.writeTo(codedOutputStream);
}
protobufSerializationTime=System.currentTimeMillis() - startTime;
var length=codedOutputStream.getTotalBytesWritten();
protobufSerializationSize=length;
var singleLength = length/benchmark;
var l=0;
//在循环中去掉创建CodedInputStream的代码,保证比较耗时公平性
var codeInputs=new CodedInputStream[benchmark];
for(int i=0;i<benchmark;i++)
{
codeInputs[i]=CodedInputStream.newInstance(protobufBuff, l+singleLength, singleLength);
}
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
var mess = FieldProtobufObject.BytesObject.parseFrom(codeInputs[i]);
}
protobufDeserializationTime=System.currentTimeMillis() - startTime;
System.out.println(StringUtils.format("序列化 [zfoo] [byte数组类型] [thread:{}] [time:{}] [size:{}]", Thread.currentThread().getName(), zfooSerializationTime,zfooSerializationSize));
System.out.println(StringUtils.format("序列化 [kryo] [byte数组类型] [thread:{}] [time:{}] [size:{}]", Thread.currentThread().getName(), kryoSerializationTime,kryoSerializationSize));
System.out.println(StringUtils.format("序列化 [protobuf] [byte数组类型] [thread:{}] [time:{}] [size:{}]", Thread.currentThread().getName(),protobufSerializationTime,protobufSerializationSize));
System.out.println(StringUtils.format("反序列化 [zfoo] [byte数组类型] [thread:{}] [time:{}]", Thread.currentThread().getName(), zfooDeserializationTime));
System.out.println(StringUtils.format("反序列化 [kryo] [byte数组类型] [thread:{}] [time:{}]", Thread.currentThread().getName(),kryoDeserializationTime));
System.out.println(StringUtils.format("反序列化 [protobuf] [byte数组类型] [thread:{}] [time:{}]", Thread.currentThread().getName(), protobufDeserializationTime));
}
@Test
public void testStringObject() throws IOException {
ByteBuf buffer = new UnpooledHeapByteBuf(ByteBufAllocator.DEFAULT, 10000_0000, 100000000);
benchmark=benchmark*3;
long startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
ProtocolManager.write(buffer,stringObject);
}
zfooSerializationTime=System.currentTimeMillis() - startTime;
zfooSerializationSize=buffer.writerIndex();
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
var packet = ProtocolManager.read(buffer);
}
zfooDeserializationTime=System.currentTimeMillis() - startTime;
buffer.release();
var kryo = kryos.get();
var output = new Output(10000_0000);
var input = new Input(output.getBuffer());
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
kryo.writeObject(output, stringObject);
}
kryoSerializationTime=System.currentTimeMillis() - startTime;
kryoSerializationSize=output.position();
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
var mess = kryo.readObject(input,StringObject.class);
}
kryoDeserializationTime=System.currentTimeMillis() - startTime;
output.close();
var protobufBuff=new byte[10000_0000];
var codedOutputStream = CodedOutputStream.newInstance(protobufBuff);
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
protobufStringObject.writeTo(codedOutputStream);
}
protobufSerializationTime=System.currentTimeMillis() - startTime;
var length=codedOutputStream.getTotalBytesWritten();
protobufSerializationSize=length;
var singleLength = length/benchmark;
var l=0;
//在循环中去掉创建CodedInputStream的代码,保证比较耗时公平性
var codeInputs=new CodedInputStream[benchmark];
for(int i=0;i<benchmark;i++)
{
codeInputs[i]=CodedInputStream.newInstance(protobufBuff, l+singleLength, singleLength);
}
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
var mess = FieldProtobufObject.StringObject.parseFrom(codeInputs[i]);
}
protobufDeserializationTime=System.currentTimeMillis() - startTime;
System.out.println(StringUtils.format("序列化 [zfoo] [string类型] [thread:{}] [time:{}] [size:{}]", Thread.currentThread().getName(), zfooSerializationTime,zfooSerializationSize));
System.out.println(StringUtils.format("序列化 [kryo] [string类型] [thread:{}] [time:{}] [size:{}]", Thread.currentThread().getName(), kryoSerializationTime,kryoSerializationSize));
System.out.println(StringUtils.format("序列化 [protobuf] [string类型] [thread:{}] [time:{}] [size:{}]", Thread.currentThread().getName(),protobufSerializationTime,protobufSerializationSize));
System.out.println(StringUtils.format("反序列化 [zfoo] [string类型] [thread:{}] [time:{}]", Thread.currentThread().getName(), zfooDeserializationTime));
System.out.println(StringUtils.format("反序列化 [kryo] [string类型] [thread:{}] [time:{}]", Thread.currentThread().getName(),kryoDeserializationTime));
System.out.println(StringUtils.format("反序列化 [protobuf] [string类型] [thread:{}] [time:{}]", Thread.currentThread().getName(), protobufDeserializationTime));
}
@Test
public void testListIntegerObject() throws IOException {
ByteBuf buffer = new UnpooledHeapByteBuf(ByteBufAllocator.DEFAULT, 10000_0000, 100000000);
long startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
ProtocolManager.write(buffer,listIntegerObject);
}
zfooSerializationTime=System.currentTimeMillis() - startTime;
zfooSerializationSize=buffer.writerIndex();
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
var packet = ProtocolManager.read(buffer);
}
zfooDeserializationTime=System.currentTimeMillis() - startTime;
buffer.release();
var kryo = kryos.get();
var output = new Output(10000_0000);
var input = new Input(output.getBuffer());
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
kryo.writeObject(output, listIntegerObject);
}
kryoSerializationTime=System.currentTimeMillis() - startTime;
kryoSerializationSize=output.position();
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
var mess = kryo.readObject(input,ListIntegerObject.class);
}
kryoDeserializationTime=System.currentTimeMillis() - startTime;
output.close();
var protobufBuff=new byte[10000_0000];
var codedOutputStream = CodedOutputStream.newInstance(protobufBuff);
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
protobufListIntegerObject.writeTo(codedOutputStream);
}
protobufSerializationTime=System.currentTimeMillis() - startTime;
var length=codedOutputStream.getTotalBytesWritten();
protobufSerializationSize=length;
var singleLength = length/benchmark;
var l=0;
//在循环中去掉创建CodedInputStream的代码,保证比较耗时公平性
var codeInputs=new CodedInputStream[benchmark];
for(int i=0;i<benchmark;i++)
{
codeInputs[i]=CodedInputStream.newInstance(protobufBuff, l+singleLength, singleLength);
}
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
var mess = FieldProtobufObject.ListIntegerObject.parseFrom(codeInputs[i]);
}
protobufDeserializationTime=System.currentTimeMillis() - startTime;
System.out.println(StringUtils.format("序列化 [zfoo] [list类型] [thread:{}] [time:{}] [size:{}]", Thread.currentThread().getName(), zfooSerializationTime,zfooSerializationSize));
System.out.println(StringUtils.format("序列化 [kryo] [list类型] [thread:{}] [time:{}] [size:{}]", Thread.currentThread().getName(), kryoSerializationTime,kryoSerializationSize));
System.out.println(StringUtils.format("序列化 [protobuf] [list类型] [thread:{}] [time:{}] [size:{}]", Thread.currentThread().getName(),protobufSerializationTime,protobufSerializationSize));
System.out.println(StringUtils.format("反序列化 [zfoo] [list类型] [thread:{}] [time:{}]", Thread.currentThread().getName(), zfooDeserializationTime));
System.out.println(StringUtils.format("反序列化 [kryo] [list类型] [thread:{}] [time:{}]", Thread.currentThread().getName(),kryoDeserializationTime));
System.out.println(StringUtils.format("反序列化 [protobuf] [list类型] [thread:{}] [time:{}]", Thread.currentThread().getName(), protobufDeserializationTime));
}
@Test
public void testSetObject() throws IOException {
ByteBuf buffer = new UnpooledHeapByteBuf(ByteBufAllocator.DEFAULT, 10000_0000, 100000000);
long startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
ProtocolManager.write(buffer,setObject);
}
zfooSerializationTime=System.currentTimeMillis() - startTime;
zfooSerializationSize=buffer.writerIndex();
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
var packet = ProtocolManager.read(buffer);
}
zfooDeserializationTime=System.currentTimeMillis() - startTime;
buffer.release();
var kryo = kryos.get();
var output = new Output(10000_0000);
var input = new Input(output.getBuffer());
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
kryo.writeObject(output, setObject);
}
kryoSerializationTime=System.currentTimeMillis() - startTime;
kryoSerializationSize=output.position();
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
var mess = kryo.readObject(input,SetObject.class);
}
kryoDeserializationTime=System.currentTimeMillis() - startTime;
output.close();
System.out.println(StringUtils.format("序列化 [zfoo] [set类型] [thread:{}] [time:{}] [size:{}]", Thread.currentThread().getName(), zfooSerializationTime,zfooSerializationSize));
System.out.println(StringUtils.format("序列化 [kryo] [set类型] [thread:{}] [time:{}] [size:{}]", Thread.currentThread().getName(), kryoSerializationTime,kryoSerializationSize));
System.out.println(StringUtils.format("反序列化 [zfoo] [set类型] [thread:{}] [time:{}]", Thread.currentThread().getName(), zfooDeserializationTime));
System.out.println(StringUtils.format("反序列化 [kryo] [set类型] [thread:{}] [time:{}]", Thread.currentThread().getName(),kryoDeserializationTime));
}
@Test
public void testMapObject() throws IOException {
ByteBuf buffer = new UnpooledHeapByteBuf(ByteBufAllocator.DEFAULT, 10000_0000, 100000000);
benchmark=benchmark/2;
long startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
ProtocolManager.write(buffer,mapObject);
}
zfooSerializationTime=System.currentTimeMillis() - startTime;
zfooSerializationSize=buffer.writerIndex();
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
var packet = ProtocolManager.read(buffer);
}
zfooDeserializationTime=System.currentTimeMillis() - startTime;
buffer.release();
var kryo = kryos.get();
var output = new Output(10000_0000);
var input = new Input(output.getBuffer());
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
kryo.writeObject(output, mapObject);
}
kryoSerializationTime=System.currentTimeMillis() - startTime;
kryoSerializationSize=output.position();
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
var mess = kryo.readObject(input,MapObject.class);
}
kryoDeserializationTime=System.currentTimeMillis() - startTime;
output.close();
var protobufBuff=new byte[10000_0000];
var codedOutputStream = CodedOutputStream.newInstance(protobufBuff);
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
protobufMapObject.writeTo(codedOutputStream);
}
protobufSerializationTime=System.currentTimeMillis() - startTime;
var length=codedOutputStream.getTotalBytesWritten();
protobufSerializationSize=length;
var singleLength = length/benchmark;
var l=0;
//在循环中去掉创建CodedInputStream的代码,保证比较耗时公平性
var codeInputs=new CodedInputStream[benchmark];
for(int i=0;i<benchmark;i++)
{
codeInputs[i]=CodedInputStream.newInstance(protobufBuff, l+singleLength, singleLength);
}
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
var mess = FieldProtobufObject.MapObject.parseFrom(codeInputs[i]);
}
protobufDeserializationTime=System.currentTimeMillis() - startTime;
System.out.println(StringUtils.format("序列化 [zfoo] [map类型] [thread:{}] [time:{}] [size:{}]", Thread.currentThread().getName(), zfooSerializationTime,zfooSerializationSize));
System.out.println(StringUtils.format("序列化 [kryo] [map类型] [thread:{}] [time:{}] [size:{}]", Thread.currentThread().getName(), kryoSerializationTime,kryoSerializationSize));
System.out.println(StringUtils.format("序列化 [protobuf] [map类型] [thread:{}] [time:{}] [size:{}]", Thread.currentThread().getName(),protobufSerializationTime,protobufSerializationSize));
System.out.println(StringUtils.format("反序列化 [zfoo] [map类型] [thread:{}] [time:{}]", Thread.currentThread().getName(), zfooDeserializationTime));
System.out.println(StringUtils.format("反序列化 [kryo] [map类型] [thread:{}] [time:{}]", Thread.currentThread().getName(),kryoDeserializationTime));
System.out.println(StringUtils.format("反序列化 [protobuf] [map类型] [thread:{}] [time:{}]", Thread.currentThread().getName(), protobufDeserializationTime));
}
@Test
public void testInnerObjectObject() throws IOException {
ByteBuf buffer = new UnpooledHeapByteBuf(ByteBufAllocator.DEFAULT, 10000_0000, 100000000);
benchmark=benchmark*2;
long startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
ProtocolManager.write(buffer,innerObjectObject);
}
zfooSerializationTime=System.currentTimeMillis() - startTime;
zfooSerializationSize=buffer.writerIndex();
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
var packet = ProtocolManager.read(buffer);
}
zfooDeserializationTime=System.currentTimeMillis() - startTime;
buffer.release();
var kryo = kryos.get();
var output = new Output(10000_0000);
var input = new Input(output.getBuffer());
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
kryo.writeObject(output, innerObjectObject);
}
kryoSerializationTime=System.currentTimeMillis() - startTime;
kryoSerializationSize=output.position();
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
var mess = kryo.readObject(input,InnerObjectObject.class);
}
kryoDeserializationTime=System.currentTimeMillis() - startTime;
output.close();
var protobufBuff=new byte[10000_0000];
var codedOutputStream = CodedOutputStream.newInstance(protobufBuff);
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
protobufInnerObjectObject.writeTo(codedOutputStream);
}
protobufSerializationTime=System.currentTimeMillis() - startTime;
var length=codedOutputStream.getTotalBytesWritten();
protobufSerializationSize=length;
var singleLength = length/benchmark;
var l=0;
//在循环中去掉创建CodedInputStream的代码,保证比较耗时公平性
var codeInputs=new CodedInputStream[benchmark];
for(int i=0;i<benchmark;i++)
{
codeInputs[i]=CodedInputStream.newInstance(protobufBuff, l+singleLength, singleLength);
}
startTime = System.currentTimeMillis();
for(int i=0;i<benchmark;i++)
{
var mess = FieldProtobufObject.InnerObjectObject.parseFrom(codeInputs[i]);
}
protobufDeserializationTime=System.currentTimeMillis() - startTime;
System.out.println(StringUtils.format("序列化 [zfoo] [内嵌Object类型] [thread:{}] [time:{}] [size:{}]", Thread.currentThread().getName(), zfooSerializationTime,zfooSerializationSize));
System.out.println(StringUtils.format("序列化 [kryo] [内嵌Object类型] [thread:{}] [time:{}] [size:{}]", Thread.currentThread().getName(), kryoSerializationTime,kryoSerializationSize));
System.out.println(StringUtils.format("序列化 [protobuf] [内嵌Object类型] [thread:{}] [time:{}] [size:{}]", Thread.currentThread().getName(),protobufSerializationTime,protobufSerializationSize));
System.out.println(StringUtils.format("反序列化 [zfoo] [内嵌Object类型] [thread:{}] [time:{}]", Thread.currentThread().getName(), zfooDeserializationTime));
System.out.println(StringUtils.format("反序列化 [kryo] [内嵌Object类型] [thread:{}] [time:{}]", Thread.currentThread().getName(),kryoDeserializationTime));
System.out.println(StringUtils.format("反序列化 [protobuf] [内嵌Object类型] [thread:{}] [time:{}]", Thread.currentThread().getName(), protobufDeserializationTime));
}
public static final int intAValue=-100000000;
public static final int intBValue=-1000000;
public static final int intCValue=-10000;
@@ -244,6 +637,7 @@ public class FieldSpeedTest {
public static final int intHValue=1000000;
public static final int intIValue=100000000;
public static final int intJValue=2147483647;
public static final int intXValue=1;
public static final float floatAValue=(float)-10000000.123;
public static final float floatBValue=(float)-100000.123;
public static final float floatCValue=(float)-1000.123;
@@ -254,7 +648,22 @@ public class FieldSpeedTest {
public static final float floatHValue=(float)1000.123;
public static final float floatIValue=(float)100000.123;
public static final float floatJValue=(float)10000000.123;
public static final byte[] bytesValue=new byte[]{-128,-90,-60,-30,0,30,60,90,120,127};
public static final String stringAValue="a";
public static final String stringBValue="ab";
public static final String stringCValue="abc";
public static final String stringDValue="abcd";
public static final String stringEValue="abcde";
public static final String stringFValue="abcdef";
public static final String stringGValue="abcdefg";
public static final String stringHValue="abcdefgh";
public static final String stringIValue="abcdefghi";
public static final String stringJValue="abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";
public static final List<Integer> listValue=new ArrayList<>(ArrayUtils.toList(new int[]{Integer.MIN_VALUE,-10000000,-100000,-1000,-10,0,10,1000,100000,10000000,Integer.MAX_VALUE}));
public static final Set<Integer> setValue=new HashSet<>(listValue);
public static final Map<Integer,String> mapValue=new HashMap<>(Map.of(Integer.MIN_VALUE,"a",-10000000,"ab",-100000,"abc",-1000,"abcd",-10,"abcde",
0,"abcdef",10,"abcdefg",1000,"abcdefgh",100000,"abcdefghi",Integer.MAX_VALUE,"abcdefghij"));
public static final InnerObject innerObjectValue=new InnerObject();
@BeforeClass
public static void prepare() {
intObject.setA(intAValue);
@@ -294,11 +703,89 @@ public class FieldSpeedTest {
protobufFloatObject=FieldProtobufObject.FloatObject.newBuilder().setA(floatAValue).setB(floatBValue).setC(floatCValue)
.setD(floatDValue).setE(floatEValue).setF(floatFValue).setG(floatGValue).setH(floatHValue).setI(floatIValue).setJ(floatJValue).build();
bytesObject.setA(bytesValue);
bytesObject.setB(bytesValue);
bytesObject.setC(bytesValue);
bytesObject.setD(bytesValue);
bytesObject.setE(bytesValue);
bytesObject.setF(bytesValue);
bytesObject.setG(bytesValue);
bytesObject.setH(bytesValue);
bytesObject.setI(bytesValue);
bytesObject.setJ(bytesValue);
protobufBytesObject=FieldProtobufObject.BytesObject.newBuilder().setA(ByteString.copyFrom(bytesValue)).setB(ByteString.copyFrom(bytesValue)).setC(ByteString.copyFrom(bytesValue))
.setD(ByteString.copyFrom(bytesValue)).setE(ByteString.copyFrom(bytesValue)).setF(ByteString.copyFrom(bytesValue)).setG(ByteString.copyFrom(bytesValue)).setH(ByteString.copyFrom(bytesValue)).setI(ByteString.copyFrom(bytesValue)).setJ(ByteString.copyFrom(bytesValue)).build();
stringObject.setA(stringAValue);
stringObject.setB(stringBValue);
stringObject.setC(stringCValue);
stringObject.setD(stringDValue);
stringObject.setE(stringEValue);
stringObject.setF(stringFValue);
stringObject.setG(stringGValue);
stringObject.setH(stringHValue);
stringObject.setI(stringIValue);
stringObject.setJ(stringJValue);
protobufStringObject=FieldProtobufObject.StringObject.newBuilder().setA(stringAValue).setB(stringBValue).setC(stringCValue)
.setD(stringDValue).setE(stringEValue).setF(stringFValue).setG(stringGValue).setH(stringHValue).setI(stringIValue).setJ(stringJValue).build();
listIntegerObject.setA(listValue);
listIntegerObject.setB(listValue);
listIntegerObject.setC(listValue);
listIntegerObject.setD(listValue);
listIntegerObject.setE(listValue);
listIntegerObject.setF(listValue);
listIntegerObject.setG(listValue);
listIntegerObject.setH(listValue);
listIntegerObject.setI(listValue);
listIntegerObject.setJ(listValue);
protobufListIntegerObject=FieldProtobufObject.ListIntegerObject.newBuilder().addAllA(listValue).addAllB(listValue).addAllC(listValue)
.addAllD(listValue).addAllE(listValue).addAllF(listValue).addAllG(listValue).addAllH(listValue).addAllI(listValue).addAllJ(listValue).build();
setObject.setA(setValue);
setObject.setB(setValue);
setObject.setC(setValue);
setObject.setD(setValue);
setObject.setE(setValue);
setObject.setF(setValue);
setObject.setG(setValue);
setObject.setH(setValue);
setObject.setI(setValue);
setObject.setJ(setValue);
mapObject.setA(mapValue);
mapObject.setB(mapValue);
mapObject.setC(mapValue);
mapObject.setD(mapValue);
mapObject.setE(mapValue);
mapObject.setF(mapValue);
mapObject.setG(mapValue);
mapObject.setH(mapValue);
mapObject.setI(mapValue);
mapObject.setJ(mapValue);
protobufMapObject=FieldProtobufObject.MapObject.newBuilder().putAllA(mapValue).putAllB(mapValue).putAllC(mapValue)
.putAllD(mapValue).putAllE(mapValue).putAllF(mapValue).putAllG(mapValue).putAllH(mapValue).putAllI(mapValue).putAllJ(mapValue).build();
innerObjectValue.setX(10000);
innerObjectObject.setA(innerObjectValue);
innerObjectObject.setB(innerObjectValue);
innerObjectObject.setC(innerObjectValue);
innerObjectObject.setD(innerObjectValue);
innerObjectObject.setE(innerObjectValue);
innerObjectObject.setF(innerObjectValue);
innerObjectObject.setG(innerObjectValue);
innerObjectObject.setH(innerObjectValue);
innerObjectObject.setI(innerObjectValue);
innerObjectObject.setJ(innerObjectValue);
var protobufInnerObject=FieldProtobufObject.InnerObject.newBuilder().setX(intXValue).build();
protobufInnerObjectObject=FieldProtobufObject.InnerObjectObject.newBuilder().setA(protobufInnerObject).setB(protobufInnerObject).setC(protobufInnerObject)
.setD(protobufInnerObject).setE(protobufInnerObject).setF(protobufInnerObject).setG(protobufInnerObject).setH(protobufInnerObject).setI(protobufInnerObject).setJ(protobufInnerObject).build();
// zfoo -----------------------------------------------------------------------
System.setProperty("io.netty.buffer.checkAccessible", "false");
System.setProperty("io.netty.buffer.checkBounds", "false");
var op = GenerateOperation.NO_OPERATION;
ProtocolManager.initProtocolAuto(Set.of(IntObject.class,IntegerObject.class,FloatObject.class), op);
ProtocolManager.initProtocolAuto(Set.of(IntObject.class,IntegerObject.class,FloatObject.class,BytesObject.class,StringObject.class,ListIntegerObject.class,SetObject.class,MapObject.class,InnerObjectObject.class), op);
}
public static final ThreadLocal<Kryo> kryos = new ThreadLocal<>() {
@@ -308,6 +795,13 @@ public class FieldSpeedTest {
kryo.register(IntObject.class);
kryo.register(IntegerObject.class);
kryo.register(FloatObject.class);
kryo.register(BytesObject.class);
kryo.register(StringObject.class);
kryo.register(ListIntegerObject.class);
kryo.register(SetObject.class);
kryo.register(MapObject.class);
kryo.register(InnerObject.class);
kryo.register(InnerObjectObject.class);
kryo.register(byte[].class);
kryo.register(Byte[].class);
kryo.register(short[].class);
@@ -0,0 +1,130 @@
package com.zfoo.protocol.field.packet;
import com.zfoo.protocol.IPacket;
import java.util.Arrays;
public class BytesObject implements IPacket {
private byte[] a;
private byte[] b;
private byte[] c;
private byte[] d;
private byte[] e;
private byte[] f;
private byte[] g;
private byte[] h;
private byte[] i;
private byte[] j;
public byte[] getA() {
return a;
}
public void setA(byte[] a) {
this.a = a;
}
public byte[] getB() {
return b;
}
public void setB(byte[] b) {
this.b = b;
}
public byte[] getC() {
return c;
}
public void setC(byte[] c) {
this.c = c;
}
public byte[] getD() {
return d;
}
public void setD(byte[] d) {
this.d = d;
}
public byte[] getE() {
return e;
}
public void setE(byte[] e) {
this.e = e;
}
public byte[] getF() {
return f;
}
public void setF(byte[] f) {
this.f = f;
}
public byte[] getG() {
return g;
}
public void setG(byte[] g) {
this.g = g;
}
public byte[] getH() {
return h;
}
public void setH(byte[] h) {
this.h = h;
}
public byte[] getI() {
return i;
}
public void setI(byte[] i) {
this.i = i;
}
public byte[] getJ() {
return j;
}
public void setJ(byte[] j) {
this.j = j;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BytesObject that = (BytesObject) o;
return Arrays.equals(a, that.a) && Arrays.equals(b, that.b) && Arrays.equals(c, that.c) && Arrays.equals(d, that.d) && Arrays.equals(e, that.e) && Arrays.equals(f, that.f) && Arrays.equals(g, that.g) && Arrays.equals(h, that.h) && Arrays.equals(i, that.i) && Arrays.equals(j, that.j);
}
@Override
public int hashCode() {
int result = Arrays.hashCode(a);
result = 31 * result + Arrays.hashCode(b);
result = 31 * result + Arrays.hashCode(c);
result = 31 * result + Arrays.hashCode(d);
result = 31 * result + Arrays.hashCode(e);
result = 31 * result + Arrays.hashCode(f);
result = 31 * result + Arrays.hashCode(g);
result = 31 * result + Arrays.hashCode(h);
result = 31 * result + Arrays.hashCode(i);
result = 31 * result + Arrays.hashCode(j);
return result;
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,30 @@
package com.zfoo.protocol.field.packet;
import com.zfoo.protocol.IPacket;
import java.util.Objects;
public class InnerObject implements IPacket {
private int x;
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
InnerObject that = (InnerObject) o;
return x == that.x;
}
@Override
public int hashCode() {
return Objects.hash(x);
}
}
@@ -0,0 +1,120 @@
package com.zfoo.protocol.field.packet;
import com.zfoo.protocol.IPacket;
import java.util.Objects;
public class InnerObjectObject implements IPacket {
private InnerObject a;
private InnerObject b;
private InnerObject c;
private InnerObject d;
private InnerObject e;
private InnerObject f;
private InnerObject g;
private InnerObject h;
private InnerObject i;
private InnerObject j;
public InnerObject getA() {
return a;
}
public void setA(InnerObject a) {
this.a = a;
}
public InnerObject getB() {
return b;
}
public void setB(InnerObject b) {
this.b = b;
}
public InnerObject getC() {
return c;
}
public void setC(InnerObject c) {
this.c = c;
}
public InnerObject getD() {
return d;
}
public void setD(InnerObject d) {
this.d = d;
}
public InnerObject getE() {
return e;
}
public void setE(InnerObject e) {
this.e = e;
}
public InnerObject getF() {
return f;
}
public void setF(InnerObject f) {
this.f = f;
}
public InnerObject getG() {
return g;
}
public void setG(InnerObject g) {
this.g = g;
}
public InnerObject getH() {
return h;
}
public void setH(InnerObject h) {
this.h = h;
}
public InnerObject getI() {
return i;
}
public void setI(InnerObject i) {
this.i = i;
}
public InnerObject getJ() {
return j;
}
public void setJ(InnerObject j) {
this.j = j;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
InnerObjectObject that = (InnerObjectObject) o;
return Objects.equals(a, that.a) && Objects.equals(b, that.b) && Objects.equals(c, that.c) && Objects.equals(d, that.d) && Objects.equals(e, that.e) && Objects.equals(f, that.f) && Objects.equals(g, that.g) && Objects.equals(h, that.h) && Objects.equals(i, that.i) && Objects.equals(j, that.j);
}
@Override
public int hashCode() {
return Objects.hash(a, b, c, d, e, f, g, h, i, j);
}
}
@@ -0,0 +1,121 @@
package com.zfoo.protocol.field.packet;
import com.zfoo.protocol.IPacket;
import java.util.List;
import java.util.Objects;
public class ListIntegerObject implements IPacket {
private List<Integer> a;
private List<Integer> b;
private List<Integer> c;
private List<Integer> d;
private List<Integer> e;
private List<Integer> f;
private List<Integer> g;
private List<Integer> h;
private List<Integer> i;
private List<Integer> j;
public List<Integer> getA() {
return a;
}
public void setA(List<Integer> a) {
this.a = a;
}
public List<Integer> getB() {
return b;
}
public void setB(List<Integer> b) {
this.b = b;
}
public List<Integer> getC() {
return c;
}
public void setC(List<Integer> c) {
this.c = c;
}
public List<Integer> getD() {
return d;
}
public void setD(List<Integer> d) {
this.d = d;
}
public List<Integer> getE() {
return e;
}
public void setE(List<Integer> e) {
this.e = e;
}
public List<Integer> getF() {
return f;
}
public void setF(List<Integer> f) {
this.f = f;
}
public List<Integer> getG() {
return g;
}
public void setG(List<Integer> g) {
this.g = g;
}
public List<Integer> getH() {
return h;
}
public void setH(List<Integer> h) {
this.h = h;
}
public List<Integer> getI() {
return i;
}
public void setI(List<Integer> i) {
this.i = i;
}
public List<Integer> getJ() {
return j;
}
public void setJ(List<Integer> j) {
this.j = j;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ListIntegerObject that = (ListIntegerObject) o;
return Objects.equals(a, that.a) && Objects.equals(b, that.b) && Objects.equals(c, that.c) && Objects.equals(d, that.d) && Objects.equals(e, that.e) && Objects.equals(f, that.f) && Objects.equals(g, that.g) && Objects.equals(h, that.h) && Objects.equals(i, that.i) && Objects.equals(j, that.j);
}
@Override
public int hashCode() {
return Objects.hash(a, b, c, d, e, f, g, h, i, j);
}
}
@@ -0,0 +1,121 @@
package com.zfoo.protocol.field.packet;
import com.zfoo.protocol.IPacket;
import java.util.Map;
import java.util.Objects;
public class MapObject implements IPacket {
private Map<Integer, String> a;
private Map<Integer, String> b;
private Map<Integer, String> c;
private Map<Integer, String> d;
private Map<Integer, String> e;
private Map<Integer, String> f;
private Map<Integer, String> g;
private Map<Integer, String> h;
private Map<Integer, String> i;
private Map<Integer, String> j;
public Map<Integer, String> getA() {
return a;
}
public void setA(Map<Integer, String> a) {
this.a = a;
}
public Map<Integer, String> getB() {
return b;
}
public void setB(Map<Integer, String> b) {
this.b = b;
}
public Map<Integer, String> getC() {
return c;
}
public void setC(Map<Integer, String> c) {
this.c = c;
}
public Map<Integer, String> getD() {
return d;
}
public void setD(Map<Integer, String> d) {
this.d = d;
}
public Map<Integer, String> getE() {
return e;
}
public void setE(Map<Integer, String> e) {
this.e = e;
}
public Map<Integer, String> getF() {
return f;
}
public void setF(Map<Integer, String> f) {
this.f = f;
}
public Map<Integer, String> getG() {
return g;
}
public void setG(Map<Integer, String> g) {
this.g = g;
}
public Map<Integer, String> getH() {
return h;
}
public void setH(Map<Integer, String> h) {
this.h = h;
}
public Map<Integer, String> getI() {
return i;
}
public void setI(Map<Integer, String> i) {
this.i = i;
}
public Map<Integer, String> getJ() {
return j;
}
public void setJ(Map<Integer, String> j) {
this.j = j;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
MapObject mapObject = (MapObject) o;
return Objects.equals(a, mapObject.a) && Objects.equals(b, mapObject.b) && Objects.equals(c, mapObject.c) && Objects.equals(d, mapObject.d) && Objects.equals(e, mapObject.e) && Objects.equals(f, mapObject.f) && Objects.equals(g, mapObject.g) && Objects.equals(h, mapObject.h) && Objects.equals(i, mapObject.i) && Objects.equals(j, mapObject.j);
}
@Override
public int hashCode() {
return Objects.hash(a, b, c, d, e, f, g, h, i, j);
}
}
@@ -0,0 +1,121 @@
package com.zfoo.protocol.field.packet;
import com.zfoo.protocol.IPacket;
import java.util.Objects;
import java.util.Set;
public class SetObject implements IPacket {
private Set<Integer> a;
private Set<Integer> b;
private Set<Integer> c;
private Set<Integer> d;
private Set<Integer> e;
private Set<Integer> f;
private Set<Integer> g;
private Set<Integer> h;
private Set<Integer> i;
private Set<Integer> j;
public Set<Integer> getA() {
return a;
}
public void setA(Set<Integer> a) {
this.a = a;
}
public Set<Integer> getB() {
return b;
}
public void setB(Set<Integer> b) {
this.b = b;
}
public Set<Integer> getC() {
return c;
}
public void setC(Set<Integer> c) {
this.c = c;
}
public Set<Integer> getD() {
return d;
}
public void setD(Set<Integer> d) {
this.d = d;
}
public Set<Integer> getE() {
return e;
}
public void setE(Set<Integer> e) {
this.e = e;
}
public Set<Integer> getF() {
return f;
}
public void setF(Set<Integer> f) {
this.f = f;
}
public Set<Integer> getG() {
return g;
}
public void setG(Set<Integer> g) {
this.g = g;
}
public Set<Integer> getH() {
return h;
}
public void setH(Set<Integer> h) {
this.h = h;
}
public Set<Integer> getI() {
return i;
}
public void setI(Set<Integer> i) {
this.i = i;
}
public Set<Integer> getJ() {
return j;
}
public void setJ(Set<Integer> j) {
this.j = j;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SetObject setObject = (SetObject) o;
return Objects.equals(a, setObject.a) && Objects.equals(b, setObject.b) && Objects.equals(c, setObject.c) && Objects.equals(d, setObject.d) && Objects.equals(e, setObject.e) && Objects.equals(f, setObject.f) && Objects.equals(g, setObject.g) && Objects.equals(h, setObject.h) && Objects.equals(i, setObject.i) && Objects.equals(j, setObject.j);
}
@Override
public int hashCode() {
return Objects.hash(a, b, c, d, e, f, g, h, i, j);
}
}
@@ -0,0 +1,111 @@
package com.zfoo.protocol.field.packet;
import com.zfoo.protocol.IPacket;
import java.util.Objects;
public class StringObject implements IPacket {
private String a;
private String b;
private String c;
private String d;
private String e;
private String f;
private String g;
private String h;
private String i;
private String j;
public String getA() {
return a;
}
public void setA(String a) {
this.a = a;
}
public String getB() {
return b;
}
public void setB(String b) {
this.b = b;
}
public String getC() {
return c;
}
public void setC(String c) {
this.c = c;
}
public String getD() {
return d;
}
public void setD(String d) {
this.d = d;
}
public String getE() {
return e;
}
public void setE(String e) {
this.e = e;
}
public String getF() {
return f;
}
public void setF(String f) {
this.f = f;
}
public String getG() {
return g;
}
public void setG(String g) {
this.g = g;
}
public String getH() {
return h;
}
public void setH(String h) {
this.h = h;
}
public String getI() {
return i;
}
public void setI(String i) {
this.i = i;
}
public String getJ() {
return j;
}
public void setJ(String j) {
this.j = j;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
StringObject that = (StringObject) o;
return Objects.equals(a, that.a) && Objects.equals(b, that.b) && Objects.equals(c, that.c) && Objects.equals(d, that.d) && Objects.equals(e, that.e) && Objects.equals(f, that.f) && Objects.equals(g, that.g) && Objects.equals(h, that.h) && Objects.equals(i, that.i) && Objects.equals(j, that.j);
}
@Override
public int hashCode() {
return Objects.hash(a, b, c, d, e, f, g, h, i, j);
}
}
@@ -28,3 +28,72 @@ message FloatObject{
float i=9;
float j=10;
}
message BytesObject{
bytes a=1;
bytes b=2;
bytes c=3;
bytes d=4;
bytes e=5;
bytes f=6;
bytes g=7;
bytes h=8;
bytes i=9;
bytes j=10;
}
message StringObject{
string a=1;
string b=2;
string c=3;
string d=4;
string e=5;
string f=6;
string g=7;
string h=8;
string i=9;
string j=10;
}
message ListIntegerObject{
repeated int32 a=1;
repeated int32 b=2;
repeated int32 c=3;
repeated int32 d=4;
repeated int32 e=5;
repeated int32 f=6;
repeated int32 g=7;
repeated int32 h=8;
repeated int32 i=9;
repeated int32 j=10;
}
message MapObject{
map<int32, string> a=1;
map<int32, string> b=2;
map<int32, string> c=3;
map<int32, string> d=4;
map<int32, string> e=5;
map<int32, string> f=6;
map<int32, string> g=7;
map<int32, string> h=8;
map<int32, string> i=9;
map<int32, string> j=10;
}
message InnerObject{
int32 x=1;
}
message InnerObjectObject{
InnerObject a=1;
InnerObject b=2;
InnerObject c=3;
InnerObject d=4;
InnerObject e=5;
InnerObject f=6;
InnerObject g=7;
InnerObject h=8;
InnerObject i=9;
InnerObject j=10;
}