use of com.alibaba.dubbo.common.serialize.support.java.CompactedObjectInputStream in project dubbo by alibaba.
the class SerializationCompareTest method testCompactedJavaOutputPerm.
@Test
public void testCompactedJavaOutputPerm() throws Exception {
Bean bean = new Bean();
int len = 0;
long now = System.currentTimeMillis();
for (int i = 0; i < 500; i++) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
CompactedObjectOutputStream out = new CompactedObjectOutputStream(os);
out.writeObject(bean);
os.close();
if (i == 0)
len = os.toByteArray().length;
ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
CompactedObjectInputStream in = new CompactedObjectInputStream(is);
assertEquals(in.readObject().getClass(), Bean.class);
}
System.out.println("compacted java write and parse 500 times in " + (System.currentTimeMillis() - now) + "ms, size " + len);
}
Aggregations