[英]What should I do to speed up a slow GWT app using MVC
I have changed my app to use MVC and it has gotten pretty slow. 我已经更改了我的应用程序以使用MVC,但它的运行速度相当缓慢。
Description: 描述:
Can someone give me some tips on what I should do to speed this app up. 有人可以给我一些有关加快该应用程序速度的提示。 Which of the above might be more CPU hungry than others, ie, is rebuilding a Tree with < 20 items on every notify() going to use that much CPU time, do I need to re-design this? 上面哪一个可能比其他CPU占用更多的CPU,例如,是否要在每个notify()上使用少于20个项目重建一棵树,这将占用那么多CPU时间,我是否需要重新设计它? Should I create a seperate interface such as SaveStateChanged that will only notify the tree, or is this just a waste of time. 我应该创建一个单独的接口(如SaveStateChanged)仅通知树,还是浪费时间。
When an application is getting slow, then most time is often not spent performing the JavaScript calculations themselves (eg I don't believe, that just calling a lot of observers is a problem - it depends on what they do!). 当应用程序变慢时,大多数时间通常不花在自己执行JavaScript计算上(例如,我不相信,仅仅调用很多观察者是一个问题-这取决于他们的工作!)。 Very often, slowness is caused by things like redundant layout (eg when each of the observers causes a layout call). 通常,速度慢是由诸如多余的布局之类的东西引起的(例如,当每个观察者引起布局调用时)。 Sometimes, lots of DOM manipulations can also be a problem (mainly with Internet Explorer). 有时,很多DOM操作也可能是一个问题(主要是Internet Explorer)。
I would suggest to play a little bit with Speed Tracer, especially the redundant layout example . 我建议您对Speed Tracer进行一些操作,尤其是冗余布局示例 。 If that's not the specific problem in your application, you should be able to take a similar approach as shown in the example to track it down. 如果这不是您应用程序中的特定问题,那么您应该能够采用示例中所示的类似方法来进行跟踪。 Use markTimeline("String")
to make special parts of your code show up clearly in Speed Tracer's graphs. 使用markTimeline("String")
可以使代码的特殊部分清晰地显示在Speed Tracer的图形中。
The first step you need to take is to isolate exactly where the performance problem is occurring. 您需要采取的第一步是准确地找出发生性能问题的位置。 You've identified some good possible candidates, but you'll want to back that up with cold hard stats. 您已经确定了一些不错的候选对象,但是您希望通过使用冷硬统计来支持。
You may find you only need to address one of the above points, or that there might be another sticking point entirely 您可能会发现您只需要解决以上问题之一,或者可能完全有另一个难点
I suggest you get rid of the Observer interface in favour of something more finegrained. 我建议您放弃Observer界面,转而使用更细粒度的内容。 Look at the MVC architecture in Swing where a JTree is associated with a TreeModel and implements TreeModelListener interface to hear of changes to the model. 查看Swing中的MVC架构,其中的JTree与TreeModel关联,并实现TreeModelListener接口以听取对模型的更改。 The TreeModelListener interface has specific methods called by the model to indicate nodes changing, being added or removed from the tree. TreeModelListener接口具有模型调用的特定方法,以指示节点正在更改,正在从树中添加或从树中删除。 In addition it has a TreeModelEvent which provides even more data about which nodes are affected. 此外,它还有一个TreeModelEvent,它提供有关受影响的节点的更多数据。 If the model tells you precisely what has changed you will have a lot more scope for reacting intelligently from your listener implementations. 如果模型准确地告诉您发生了什么变化,您将有更大的空间来从侦听器实现中做出明智的反应。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.