del[protocol]: remove fury test, record not support

This commit is contained in:
sun committed 2023-09-22 10:27:10 +08:00
1 parent ce9cc21fea
commit bbcae91ec3
4 files changed
+87 -158

No files matched your search

+13 -13
View File
@@ -124,22 +124,22 @@
<dependency> <dependency>
<groupId>com.esotericsoftware</groupId> <groupId>com.esotericsoftware</groupId>
<artifactId>kryo</artifactId> <artifactId>kryo</artifactId>
<version>5.3.0</version> <version>5.5.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <!-- <dependency>-->
<groupId>org.furyio</groupId> <!-- <groupId>org.furyio</groupId>-->
<artifactId>fury-core</artifactId> <!-- <artifactId>fury-core</artifactId>-->
<version>0.1.0</version> <!-- <version>0.1.0</version>-->
<scope>test</scope> <!-- <scope>test</scope>-->
<exclusions> <!-- <exclusions>-->
<exclusion> <!-- <exclusion>-->
<artifactId>slf4j-api</artifactId> <!-- <artifactId>slf4j-api</artifactId>-->
<groupId>org.slf4j</groupId> <!-- <groupId>org.slf4j</groupId>-->
</exclusion> <!-- </exclusion>-->
</exclusions> <!-- </exclusions>-->
</dependency> <!-- </dependency>-->
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
@@ -24,11 +24,6 @@ import com.zfoo.protocol.collection.ArrayUtils;
import com.zfoo.protocol.generate.GenerateOperation; import com.zfoo.protocol.generate.GenerateOperation;
import com.zfoo.protocol.packet.*; import com.zfoo.protocol.packet.*;
import com.zfoo.protocol.util.StringUtils; import com.zfoo.protocol.util.StringUtils;
import io.fury.Fury;
import io.fury.Language;
import io.fury.ThreadLocalFury;
import io.fury.ThreadSafeFury;
import io.fury.memory.MemoryBuffer;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator; import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.UnpooledHeapByteBuf; import io.netty.buffer.UnpooledHeapByteBuf;
@@ -68,7 +63,7 @@ public class BenchmarkTesting {
System.out.println(StringUtils.format("[单线程性能测试-->[benchmark:{}]]", benchmark)); System.out.println(StringUtils.format("[单线程性能测试-->[benchmark:{}]]", benchmark));
zfooTest(); zfooTest();
furyTest(); // furyTest();
protobufTest(); protobufTest();
kryoTest(); kryoTest();
@@ -90,7 +85,7 @@ public class BenchmarkTesting {
System.out.println(StringUtils.format("[多线程性能测试-->[benchmark:{}]]", benchmark)); System.out.println(StringUtils.format("[多线程性能测试-->[benchmark:{}]]", benchmark));
zfooMultipleThreadTest(); zfooMultipleThreadTest();
furyMultipleThreadTest(); // furyMultipleThreadTest();
protobufMultipleThreadTest(); protobufMultipleThreadTest();
kryoMultipleThreadTest(); kryoMultipleThreadTest();
@@ -142,41 +137,41 @@ public class BenchmarkTesting {
System.out.println(StringUtils.format("[zfoo] [复杂对象] [thread:{}] [size:{}] [time:{}]", Thread.currentThread().getName(), buffer.writerIndex(), System.currentTimeMillis() - startTime)); System.out.println(StringUtils.format("[zfoo] [复杂对象] [thread:{}] [size:{}] [time:{}]", Thread.currentThread().getName(), buffer.writerIndex(), System.currentTimeMillis() - startTime));
} }
@Test // @Test
public void furyTest() { // public void furyTest() {
var buffer = MemoryBuffer.newHeapBuffer(1_0000); // var buffer = MemoryBuffer.newHeapBuffer(1_0000);
// 序列化和反序列化简单对象 // // 序列化和反序列化简单对象
long startTime = System.currentTimeMillis(); // long startTime = System.currentTimeMillis();
for (int i = 0; i < benchmark; i++) { // for (int i = 0; i < benchmark; i++) {
buffer.writerIndex(0); // buffer.writerIndex(0);
buffer.readerIndex(0); // buffer.readerIndex(0);
fury.serialize(buffer, simpleObject); // fury.serialize(buffer, simpleObject);
var obj = fury.deserialize(buffer); // var obj = fury.deserialize(buffer);
} // }
//
System.out.println(StringUtils.format("[fury] [简单对象] [thread:{}] [size:{}] [time:{}]", Thread.currentThread().getName(), buffer.writerIndex(), System.currentTimeMillis() - startTime)); // System.out.println(StringUtils.format("[fury] [简单对象] [thread:{}] [size:{}] [time:{}]", Thread.currentThread().getName(), buffer.writerIndex(), System.currentTimeMillis() - startTime));
//
// 序列化和反序列化常规对象 // // 序列化和反序列化常规对象
startTime = System.currentTimeMillis(); // startTime = System.currentTimeMillis();
for (int i = 0; i < benchmark; i++) { // for (int i = 0; i < benchmark; i++) {
buffer.writerIndex(0); // buffer.writerIndex(0);
buffer.readerIndex(0); // buffer.readerIndex(0);
fury.serialize(buffer, normalObject); // fury.serialize(buffer, normalObject);
var obj = fury.deserialize(buffer); // var obj = fury.deserialize(buffer);
} // }
//
System.out.println(StringUtils.format("[fury] [常规对象] [thread:{}] [size:{}] [time:{}]", Thread.currentThread().getName(), buffer.writerIndex(), System.currentTimeMillis() - startTime)); // System.out.println(StringUtils.format("[fury] [常规对象] [thread:{}] [size:{}] [time:{}]", Thread.currentThread().getName(), buffer.writerIndex(), System.currentTimeMillis() - startTime));
//
// 序列化和反序列化复杂对象 // // 序列化和反序列化复杂对象
startTime = System.currentTimeMillis(); // startTime = System.currentTimeMillis();
for (int i = 0; i < benchmark; i++) { // for (int i = 0; i < benchmark; i++) {
buffer.writerIndex(0); // buffer.writerIndex(0);
buffer.readerIndex(0); // buffer.readerIndex(0);
fury.serialize(buffer, complexObject); // fury.serialize(buffer, complexObject);
var obj = fury.deserialize(buffer); // var obj = fury.deserialize(buffer);
} // }
System.out.println(StringUtils.format("[fury] [复杂对象] [thread:{}] [size:{}] [time:{}]", Thread.currentThread().getName(), buffer.writerIndex(), System.currentTimeMillis() - startTime)); // System.out.println(StringUtils.format("[fury] [复杂对象] [thread:{}] [size:{}] [time:{}]", Thread.currentThread().getName(), buffer.writerIndex(), System.currentTimeMillis() - startTime));
} // }
@Test @Test
public void kryoTest() { public void kryoTest() {
@@ -278,17 +273,17 @@ public class BenchmarkTesting {
countdown.await(); countdown.await();
} }
@Test // @Test
public void furyMultipleThreadTest() throws InterruptedException { // public void furyMultipleThreadTest() throws InterruptedException {
var countdown = new CountDownLatch(threadNum); // var countdown = new CountDownLatch(threadNum);
for (var i = 0; i < threadNum; i++) { // for (var i = 0; i < threadNum; i++) {
executors[i].execute(() -> { // executors[i].execute(() -> {
furyTest(); // furyTest();
countdown.countDown(); // countdown.countDown();
}); // });
} // }
countdown.await(); // countdown.await();
} // }
@Test @Test
public void kryoMultipleThreadTest() throws InterruptedException { public void kryoMultipleThreadTest() throws InterruptedException {
@@ -364,21 +359,21 @@ public class BenchmarkTesting {
} }
} }
private static ThreadSafeFury fury; // private static ThreadSafeFury fury;
//
static { // static {
fury = new ThreadLocalFury(classLoader -> { // fury = new ThreadLocalFury(classLoader -> {
Fury f = Fury.builder().withLanguage(Language.JAVA) // Fury f = Fury.builder().withLanguage(Language.JAVA)
.build(); // .build();
f.register(ComplexObject.class); // f.register(ComplexObject.class);
f.register(NormalObject.class); // f.register(NormalObject.class);
f.register(SimpleObject.class); // f.register(SimpleObject.class);
f.register(VeryBigObject.class); // f.register(VeryBigObject.class);
f.register(ObjectA.class); // f.register(ObjectA.class);
f.register(ObjectB.class); // f.register(ObjectB.class);
return f; // return f;
}); // });
} // }
// -------------------------------------------以下为测试用例--------------------------------------------------------------- // -------------------------------------------以下为测试用例---------------------------------------------------------------
// 简单类型 // 简单类型
@@ -404,10 +399,10 @@ public class BenchmarkTesting {
public static final double[] doubleArray = new double[]{Double.MIN_VALUE, -99999999.9F, -99.9D, 0D, 99.9D, 99999999.9F, Double.MAX_VALUE}; public static final double[] doubleArray = new double[]{Double.MIN_VALUE, -99999999.9F, -99.9D, 0D, 99.9D, 99999999.9F, Double.MAX_VALUE};
public static final char[] charArray = new char[]{'a', 'b', 'c', 'd', 'e'}; public static final char[] charArray = new char[]{'a', 'b', 'c', 'd', 'e'};
public static final String[] stringArray = new String[]{"a", "b", "c", "d", "e"}; public static final String[] stringArray = new String[]{"a", "b", "c", "d", "e"};
public static final ObjectA objectA = new ObjectA();
public static final ObjectB objectB = new ObjectB();
public static final Map<Integer, String> mapWithInteger = new HashMap<>(Map.of(Integer.MIN_VALUE, "a", -99, "b", 0, "c", 99, "d", Integer.MAX_VALUE, "e")); public static final Map<Integer, String> mapWithInteger = new HashMap<>(Map.of(Integer.MIN_VALUE, "a", -99, "b", 0, "c", 99, "d", Integer.MAX_VALUE, "e"));
public static final ObjectB objectB = new ObjectB(true);
public static final ObjectA objectA = new ObjectA(Integer.MAX_VALUE, mapWithInteger, objectB);
public static final List<Integer> listWithInteger = new ArrayList<>(ArrayUtils.toList(intArray)); public static final List<Integer> listWithInteger = new ArrayList<>(ArrayUtils.toList(intArray));
public static final List<Integer> listWithInteger1 = new ArrayList<>(ArrayUtils.toList(intArray1)); public static final List<Integer> listWithInteger1 = new ArrayList<>(ArrayUtils.toList(intArray1));
public static final List<Integer> listWithInteger2 = new ArrayList<>(ArrayUtils.toList(intArray2)); public static final List<Integer> listWithInteger2 = new ArrayList<>(ArrayUtils.toList(intArray2));
@@ -445,12 +440,6 @@ public class BenchmarkTesting {
public static ProtobufObject.ProtobufNormalObject protobufNormalObject = null; public static ProtobufObject.ProtobufNormalObject protobufNormalObject = null;
public static ProtobufObject.ProtobufSimpleObject protobufSimpleObject = null; public static ProtobufObject.ProtobufSimpleObject protobufSimpleObject = null;
static {
objectA.setA(Integer.MAX_VALUE);
objectA.setM(mapWithInteger);
objectA.setObjectB(objectB);
objectB.setFlag(false);
}
static { static {
complexObject.setA(byteValue); complexObject.setA(byteValue);
@@ -17,56 +17,17 @@ package com.zfoo.protocol.packet;
import com.zfoo.protocol.anno.Protocol; import com.zfoo.protocol.anno.Protocol;
import java.util.Map; import java.util.Map;
import java.util.Objects;
/** /**
* @author godotg * @author godotg
*/ */
@Protocol(id = 102) @Protocol(id = 102)
public class ObjectA { public record ObjectA(
private int a; int a,
private Map<Integer, String> m; Map<Integer, String> m,
private ObjectB objectB; ObjectB objectB
) {
public int getA() {
return a;
}
public void setA(int a) {
this.a = a;
}
public Map<Integer, String> getM() {
return m;
}
public void setM(Map<Integer, String> m) {
this.m = m;
}
public ObjectB getObjectB() {
return objectB;
}
public void setObjectB(ObjectB objectB) {
this.objectB = objectB;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ObjectA objectA = (ObjectA) o;
return a == objectA.a &&
Objects.equals(m, objectA.m) &&
Objects.equals(objectB, objectA.objectB);
}
@Override
public int hashCode() {
return Objects.hash(a, m, objectB);
}
} }
@@ -16,35 +16,14 @@ package com.zfoo.protocol.packet;
import com.zfoo.protocol.anno.Protocol; import com.zfoo.protocol.anno.Protocol;
import java.util.Objects;
/** /**
* @author godotg * @author godotg
*/ */
@Protocol(id = 103) @Protocol(id = 103)
public class ObjectB { public record ObjectB(
private boolean flag; boolean flag
public boolean isFlag() { ) {
return flag;
}
public void setFlag(boolean flag) {
this.flag = flag;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ObjectB objectB = (ObjectB) o;
return flag == objectB.flag;
}
@Override
public int hashCode() {
return Objects.hash(flag);
}
} }