FastBinaryEncoding icon indicating copy to clipboard operation
FastBinaryEncoding copied to clipboard

Benchmarks for Java/Kotlin should parse/serialize from/to a byte array or java.nio.ByteBuffer instead of String

Open plokhotnyuk opened this issue 5 years ago • 2 comments

Currently benchmarks test only half of the real use case, because usually we receive/send buffered bytes from the wire or disks, not strings.

plokhotnyuk avatar Jan 01 '19 16:01 plokhotnyuk

For send/receive scenario I can suggest looking into SendReceive example where you can feed Receiver with byte[] data and get corresponding handlers called:

public class Receiver
{
...
    public void receive(byte[] buffer);
    public void receive(byte[] buffer, long offset, long size);
...
    // Receive handlers
    protected void onReceive(proto.Order value) {}
    protected void onReceive(proto.Balance value) {}
    protected void onReceive(proto.Account value) {}
}

chronoxor avatar Jan 01 '19 17:01 chronoxor

Java benchmarks use byte[] based dynamic buffer to serrialize/deserialize objects.

Also this Buffer has methods to attach any byte[] data to serrialize/deserialize objects:

public class Buffer
{
...
    public void attach(byte[] buffer) { _data = buffer; _size = buffer.length; _offset = 0; }
    public void attach(byte[] buffer, long offset) { _data = buffer; _size = buffer.length; _offset = offset; }
    public void attach(byte[] buffer, long size, long offset) { _data = buffer; _size = size; _offset = offset; }
...
}

chronoxor avatar Jan 01 '19 17:01 chronoxor