I have noticed that quite a few JsonParser (including DSL Json, JsonIter, LoganSquare, etc.) have the option of parsing an InputStream, instead of a string. The idea is that You don't have to waste extra time to convert an InputString to a String, but You can parse an InputStream directly, by reading the bytes of the inputstream.
I would like to compare the performance of converting the inputstream to string and then parsing it, vs parsing an inputstream or even a bufferedinputstream directly. However, every parser requires to know the buffer size of the parser.
I have the following questions:
- What is an ideal buffer size that works well in most cases?
- How a small buffer size affects the performance?
- How a large buffer size affects the performance?
- Is there any way to find the ideal buffer size, if we can approximate the number of characters that will be read through the stream?
Thanks.