mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-05-25 21:59:38 +00:00
test[protocol]: kryo搞版本运行报错提示
This commit is contained in:
@@ -139,42 +139,47 @@ public class SpeedTest {
|
||||
@Ignore
|
||||
@Test
|
||||
public void kryoTest() {
|
||||
var kryo = kryos.get();
|
||||
try {
|
||||
var kryo = kryos.get();
|
||||
|
||||
var output = new UnsafeOutput(1024 * 8);
|
||||
var input = new UnsafeInput(output.getBuffer());
|
||||
var output = new UnsafeOutput(1024 * 8);
|
||||
var input = new UnsafeInput(output.getBuffer());
|
||||
|
||||
// 序列化和反序列化简单对象
|
||||
long startTime = System.currentTimeMillis();
|
||||
for (int i = 0; i < benchmark; i++) {
|
||||
input.reset();
|
||||
output.reset();
|
||||
kryo.writeObject(output, simpleObject);
|
||||
var mess = kryo.readObject(input, SimpleObject.class);
|
||||
// 序列化和反序列化简单对象
|
||||
long startTime = System.currentTimeMillis();
|
||||
for (int i = 0; i < benchmark; i++) {
|
||||
input.reset();
|
||||
output.reset();
|
||||
kryo.writeObject(output, simpleObject);
|
||||
var mess = kryo.readObject(input, SimpleObject.class);
|
||||
}
|
||||
|
||||
System.out.println(StringUtils.format("[kryo] [简单对象] [thread:{}] [size:{}] [time:{}]", Thread.currentThread().getName(), output.position(), System.currentTimeMillis() - startTime));
|
||||
|
||||
// 序列化和反序列化常规对象
|
||||
startTime = System.currentTimeMillis();
|
||||
for (int i = 0; i < benchmark; i++) {
|
||||
input.reset();
|
||||
output.reset();
|
||||
kryo.writeObject(output, normalObject);
|
||||
var mess = kryo.readObject(input, NormalObject.class);
|
||||
}
|
||||
|
||||
System.out.println(StringUtils.format("[kryo] [常规对象] [thread:{}] [size:{}] [time:{}]", Thread.currentThread().getName(), output.position(), System.currentTimeMillis() - startTime));
|
||||
|
||||
// 序列化和反序列化复杂对象
|
||||
startTime = System.currentTimeMillis();
|
||||
for (int i = 0; i < benchmark; i++) {
|
||||
input.reset();
|
||||
output.reset();
|
||||
kryo.writeObject(output, complexObject);
|
||||
var mess = kryo.readObject(input, ComplexObject.class);
|
||||
}
|
||||
System.out.println(StringUtils.format("[kryo] [复杂对象] [thread:{}] [size:{}] [time:{}]", Thread.currentThread().getName(), output.position(), System.currentTimeMillis() - startTime));
|
||||
} catch (Exception e) {
|
||||
System.err.println(e.getMessage());
|
||||
System.err.println("JDK17 运行kryo会报错,等kryo修复bug");
|
||||
}
|
||||
|
||||
System.out.println(StringUtils.format("[kryo] [简单对象] [thread:{}] [size:{}] [time:{}]", Thread.currentThread().getName(), output.position(), System.currentTimeMillis() - startTime));
|
||||
|
||||
// 序列化和反序列化常规对象
|
||||
startTime = System.currentTimeMillis();
|
||||
for (int i = 0; i < benchmark; i++) {
|
||||
input.reset();
|
||||
output.reset();
|
||||
kryo.writeObject(output, normalObject);
|
||||
var mess = kryo.readObject(input, NormalObject.class);
|
||||
}
|
||||
|
||||
System.out.println(StringUtils.format("[kryo] [常规对象] [thread:{}] [size:{}] [time:{}]", Thread.currentThread().getName(), output.position(), System.currentTimeMillis() - startTime));
|
||||
|
||||
// 序列化和反序列化复杂对象
|
||||
startTime = System.currentTimeMillis();
|
||||
for (int i = 0; i < benchmark; i++) {
|
||||
input.reset();
|
||||
output.reset();
|
||||
kryo.writeObject(output, complexObject);
|
||||
var mess = kryo.readObject(input, ComplexObject.class);
|
||||
}
|
||||
System.out.println(StringUtils.format("[kryo] [复杂对象] [thread:{}] [size:{}] [time:{}]", Thread.currentThread().getName(), output.position(), System.currentTimeMillis() - startTime));
|
||||
}
|
||||
|
||||
@Ignore
|
||||
|
||||
Reference in New Issue
Block a user