问题描述
我有一个关于如何预处理java的问题。我实施了一些建议,我能够得到它的工作。只关注表现。
我尝试了两种方法:
一种方法是使用gson将其倾倒成哈希映射。然后在吸气人员看着地图阅读。这花了12秒钟。
我尝试了一种方法。我为两种json格式创建了两个类。基于源我使用jaskson将其映射到各自的类。我在规范化的类(具有通用名称的类)上创建。现在我正在使用推土机库将其映射到标准化的类。最后,我所有的结果都是标准化的类对象集合。现在需要8秒钟
我想知道是否有更快的方法来完成这项工作。我认为在这两种情况下,头顶上都会创造1000个我不想要的物体。我需要的只是将它们显示在表格的前端。
使用正则表达式处理原始json是一个不错的选择吗?
线程帮助吗?
其他建议?
谢谢
如果您需要,您可以使用Jackson的流解析器来实现超快速的性能。虽然在做之前我会认真地做一些适当的基准测试,因为解析1000个对象的时间比Jackson少8秒。请参阅此系列;如果您可以克隆回购并使您的类在该框架内工作,那么您将会对杰克逊如何处理您的数据类有个很好的理解。我怀疑你的问题不是杰克逊,而是你的代码中的其他地方:一个探查器可以帮助很多。
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.
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
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.
这篇关于Json预处理性能问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!