Search in sources :

Example 1 with CompactedObjectInputStream

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);
}
Also used : CompactedObjectOutputStream(com.alibaba.dubbo.common.serialize.support.java.CompactedObjectOutputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) CompactedObjectInputStream(com.alibaba.dubbo.common.serialize.support.java.CompactedObjectInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Aggregations

CompactedObjectInputStream (com.alibaba.dubbo.common.serialize.support.java.CompactedObjectInputStream)1 CompactedObjectOutputStream (com.alibaba.dubbo.common.serialize.support.java.CompactedObjectOutputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 Test (org.junit.Test)1