Monday 19 December 2016

Choosing the best data representation format for Android

I recently did a PoC to evaluate which data representation format suits for small or mid sized data. Would like to share my observations of the same.

If you don't know about MessagePack and FlatBuffer. Visit the official sites to know more about them.

MessagePack

FlatBuffer

Comparison of sizes of different data representation formats (for small JSON files)


Json
Message pack
Flat buffer
Without GZip (bytes)
958
722
1,028
With GZip (bytes)
309
324
493

Observation:

  • Plain MessagePack is better than JSON, but upon GZipping JSON is better (in terms of size)
  • Flat buffer takes more size as compared to JSON / MessagePack, but gives us the advantage of accessing the data without deserializing

Conclusion:

It is better to stick to JSON + gzip way of data representation and compression. It is more efficient than message pack and Flat buffers in terms of size. Also deserializing takes more time in Message Pack

Flat buffer eliminate the need of deserialization of data at the client end but we can observe any effect only if the data is being loaded from the device cache. In case of loading from the network the incremental benefit of around 15ms (average time to deserialize small data) is negligible compared to the efforts needed for replacement.


1 comment:

  1. Hello! Just wanted to ask (if there's anyone here), if this blog has been moved to another site, or whatever happened. I'm interested in the content.

    ReplyDelete