chronoxor / FastBinaryEncoding

Fast Binary Encoding is ultra fast and universal serialization solution for C++, C#, Go, Java, JavaScript, Kotlin, Python, Ruby, Swift
https://chronoxor.github.io/FastBinaryEncoding
MIT License
827 stars 86 forks source link

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

Open plokhotnyuk opened 5 years ago

plokhotnyuk commented 5 years ago

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

chronoxor commented 5 years ago

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 commented 5 years ago

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; }
...
}