问题
I have a question here on how to pre process java. I implemented some suggestions and i am able to get it to work. Only concern is performance.
Json pre processing in java
I experimented two ways:
one way is using gson i dumped it into hash map. then in getters i look into map to read. It took 12 seconds to do it.
I tried one more approach. I created two classes for two json formats. based on source i am using jaskson to map it to respective class.I created on normalized class( class with general names). Now i am using dozer library to map it to normalized class. In the end all my results are set of normalized class objects. It is taking 8 sec now
I am wondering if there is a quicker way to get this work done. I think in both cases the over head is creating 1000's of objects which i dont want. All i need is to display them in front end in a table.
Does manipulating raw json using regex a good option?
Does threading help?
Any other suggestions?
Thanks
回答1:
You can probably use Jackson's stream parser for super-fast performance, if it's what you require. Although before doing so I would seriously do some proper benchmarking, because parsing 1000 objects takes way less then 8 seconds with Jackson. See this benchmark serie; if you can clone the repo and adapt your classes to work inside that framework, you'll get an excellent idea of how Jackson behaves with your data class. I suspect that your problem is not with Jackson but with someplace else in your code: a profiler can help a lot in there.
来源:https://stackoverflow.com/questions/15794393/json-preprocessing-performance-issue