use of com.alibaba.com.caucho.hessian.io.Hessian2Output in project dubbo by alibaba.
the class SerializationCompareTest method test_CompareSerializeLength.
@Test
public void test_CompareSerializeLength() throws Exception {
long[] data = new long[] { -1l, 2l, 3l, 4l, 5l };
ByteArrayOutputStream os;
os = new ByteArrayOutputStream();
ObjectOutputStream jos = new ObjectOutputStream(os);
jos.writeObject(data);
System.out.println("java:" + Bytes.bytes2hex(os.toByteArray()) + ":" + os.size());
os = new ByteArrayOutputStream();
CompactedObjectOutputStream oos = new CompactedObjectOutputStream(os);
oos.writeObject(data);
System.out.println("compacted java:" + Bytes.bytes2hex(os.toByteArray()) + ":" + os.size());
os = new ByteArrayOutputStream();
Hessian2Output h2o = new Hessian2Output(os);
h2o.writeObject(data);
h2o.flushBuffer();
System.out.println("hessian:" + Bytes.bytes2hex(os.toByteArray()) + ":" + os.size());
os = new ByteArrayOutputStream();
Builder<long[]> lb = Builder.register(long[].class);
lb.writeTo(data, os);
System.out.println("DataOutput:" + Bytes.bytes2hex(os.toByteArray()) + ":" + os.size());
}
Aggregations