Hello,
I am doing some performance tests accross serveral serialization formats
including Avro/FlatBuffer/Thrift and etc.
Test bases on deserializing a message having 30 long type fields for 1,000,000
times.
Test code for Avro as below:
byte[] bytes = readFromFile("market.avro");
long begin = System.nanoTime();
DatumReader<Market> userDatumReader = new ReflectDatumReader<>(Market.class);
InputStream inputStream = new SeekableByteArrayInput(bytes);
BinaryDecoder reuse = DecoderFactory.get().binaryDecoder(inputStream, null);
Market marketReuse = new Market();
for (int i = 0; i < loopCount; i++) {
inputStream = new SeekableByteArrayInput(bytes);
BinaryDecoder decoder = DecoderFactory.get().binaryDecoder(inputStream,
reuse);
userDatumReader.read(marketReuse, decoder);
}
long end = System.nanoTime() - begin;
System.out.println("avro loop " + loopCount + " times: " + (end * 1d / 1000 /
1000));
However, the result for avro is not good enough. Since the result for thrift
and protobuf is about 2,000 milliseconds, but avro uses about 8,000
milliseconds.
I believe I do something wrong about coding, but I am not sure what's the
point. Do I make the 'reuse' in a wrong way?
Any advice? Thanks in advance.
[email protected]