I am using message-pack lib (https://github.com/msgpack/msgpack-java) for an android app and unpacking the data from streaming apis form the received InputStream. The transmission is fast and overall it works good, but the at the client side (i.e. the android app), while unpacking the stream, The parsing takes too long.
There is one single line of code that takes away around 600-800ms for data of size 16.65kb.
ImmutableValue val = unpacker.unpackValue();
**JSONObject jsonObj=new JOSNObject(val.toString());**
How can I make this faster? Its less than 50ms in iOS phone using MPMessagePack library which does the parsing in C language internally.
Here are the things I have already tried.
- Tried the wrapper lib https://github.com/msgpack/msgpack-java/blob/develop/msgpack-jackson/README.md that directly parses the data into models. Its equally slow.
- Tried another lib okSSE but that uses a different encoding while message-pack lib used a different one.
- Tried to traverse the whole ImmutableMapValue and putting key-values into JSONObject. That takes equal time as well.
- Tried to write my own parsing but that doesn't seem to speed up either.
If any one of you have faced the same issue with message-pack library and found out how to optimise this step, please share in the answer section below.