Json preprocessing performance issue

痞子三分冷 提交于 2019-12-22 01:19:22

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!