netresearch/jsonmapper — pull request #8 by Jalle19 (2014-09-09 08:08:38+00:00)
Title: Performance improvements

I'm using this library in an application that reads hundreds (sometimes thousands) of JSON objects from an API which are then mapped to fairly complex objects. As I've been adding more properties to my classes I've noticed some pretty serious performance regressions so I had to start investigating.

This set of patches improves performance on large sets of objects my about 50% (in a simulated test case the total runtime decreased from ~8 seconds to ~4). The main culprit is that `inspectProperty()` is run every time `map()` is called, even though it's the same type of object that is being inspected during each iteration. I've added a runtime cache to hold the inspection results which speeds up `map()` considerably.

I'm still looking into whether `setProperty()` can be optimized since after `inspectProperty()` that's the method that gets called the most. Caching the reflection results somehow should do the trick but there may be a better solution.