Java JSON Parser Buffer Size for InputStream

Viewed 83

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:

  1. What is an ideal buffer size that works well in most cases?
  2. How a small buffer size affects the performance?
  3. How a large buffer size affects the performance?
  4. 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.

0 Answers
Related