我应该怎么做才能加快使用MVC的慢GWT应用程序 [英] What should I do to speed up a slow GWT app using MVC
问题描述
描述:
- 应用程序有5个组合,每个组合代表不同的数据,并不总是显示
- 该应用程序使用MVC,我将模型传递给每个当发生更新时复合。
- 每次收到通知时,我都会重新构建树(以及所有树项),但是,只有其中一个树项会发生更改,所以这是可能是浪费。
- 由于应用程序的风格,我甚至必须通知()以获取无关紧要的内容,例如更改文本框中的文本或选择菜单,因为我有一个保存的图标那么只要树项中的某些内容发生更改,它就会变为未保存。 所有组合实现相同的Observer接口,因此每个notify()都会得到更新。
我的应用程序使用MVC并且变得非常慢。
有人可以给我一些提示,告诉我应该如何加快这款应用的速度。以上哪一个可能比其他CPU更饿,即正在用<每个notify()函数将使用20个CPU时间,我需要重新设计它吗?我应该创建一个单独的接口,如SaveStateChanged,它只会通知树,或者这只是浪费时间。
解决方案当应用程序变慢时,大多数时间通常不会花费在自己执行JavaScript计算上(例如,我不相信,只是调用很多观察者是一个问题 - 这取决于他们是什么做!)。很多时候,缓慢是由诸如冗余布局之类的事情引起的(例如,当每个观察者导致布局调用时)。有时候,大量的DOM操作也可能成为问题(主要是IE浏览器)。
我建议在Speed Tracer上玩一点,特别是冗余布局示例。如果这不是您的应用程序中的特定问题,您应该可以采取与示例中所示类似的方法进行跟踪。使用 markTimeline(String)
,以便在Speed Tracer的图表中清楚地显示代码的特殊部分。
I have changed my app to use MVC and it has gotten pretty slow.
Description:
- The application has a number of 5 composites, each composite represents different data and is not always showing
- The app is using MVC and I am passing the model to each composite when an update occurs.
- I am rebuilding a Tree (and all tree items) every time a notify is recieved, however, only one of the tree items would have changed, so this is possibly a waste.
- Due to the style of the app I have to even notify() for insignificant things like changing the text in a text box or selecting a menu because I have a saved icon that turn to unsaved whenever something is changed in the tree Item.
- All the composites are implementing the same Observer Interface, so all are getting updated on every notify().
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? Should I create a seperate interface such as SaveStateChanged that will only notify the tree, or is this just a waste of time.
When an application is getting slow, then most time is often not spent performing the JavaScript calculations themselves (e. g. I don't believe, that just calling a lot of observers is a problem - it depends on what they do!). Very often, slowness is caused by things like redundant layout (e. g. when each of the observers causes a layout call). Sometimes, lots of DOM manipulations can also be a problem (mainly with Internet Explorer).
I would suggest to play a little bit with Speed Tracer, especially the redundant layout example. 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.
这篇关于我应该怎么做才能加快使用MVC的慢GWT应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!