Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I wrote "<a href="http://www.cowtowncoder.com/blog/archives/2011/05/entry_455.html" rel="noreferrer">On proper performance testing of Java JSON processing</a>" a while ago, to enumerate common problems I have seen with performance benchmarking. There are lots of relatively simple ways to mess up comparison. I am assuming you are not making any of mistakes mentioned, but it is worth mentioning. Especially part about using raw input: there are very few cases where real JSON data comes as <code>String</code> -- so make sure to use <code>InputStream</code> / <code>OutputStream</code> (or byte arrays).</p> <p>Second thing to note that is that if you use tree model (like <code>JsonObject</code>) you are already adding lots of potentially avoidable overhead: you are building a <code>Map</code>/<code>List</code> structures that use 3x memory that POJOs would use; and are slower to operate on. In this case, actual parsing/generation overhead is typically minority component anyway. Sometimes tree style processing makes sense, and this is acceptable overhead.</p> <p>So if performance matters a lot, one typically either:</p> <ol> <li>Uses streaming API to build your own objects -- not an in-memory tree, or</li> <li>Uses data-binding to/from POJOs. This can be close to speed of (1)</li> </ol> <p>both of which will be faster than building trees (and to some degree, serializing). For some reason many developers somehow assume that dealing with tree representations is as efficient way to deal with data as any -- this is not the case, and seen in benchmarks like <a href="https://github.com/eishay/jvm-serializers" rel="noreferrer">https://github.com/eishay/jvm-serializers</a></p> <p>I did not see Jackson-related code via link, so I am assuming it works as expected. The main things to look for (wrt performance probs) really are to:</p> <ol> <li>Always close <code>JsonParser</code> and <code>JsonGenerator</code> (needed for some of recycling) and</li> <li>Reuse <code>JsonFactory</code> and/or <code>ObjectMapper</code> instances: they are thread-safe, reuse of some components (symbol tables, serializers) occurs through these objects.</li> <li>As mentioned earlier, always use most raw input/output destinations if possible (<code>InputStream</code>, <code>OutputStream</code>).</li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload