如何加速 gwt 编译器? [英] How do I speed up the gwt compiler?

查看:23
本文介绍了如何加速 gwt 编译器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们开始在我们的项目中更多地使用 GWT,而 GWT 编译器的性能变得越来越令人讨厌.

We're starting to make heavier use of GWT in our projects, and the performance of the GWT compiler is becoming increasingly annoying.

我们将开始改变我们的工作实践来缓解这个问题,包括更加强调托管模式浏览器,它将运行 GWT 编译器的需要推迟到以后,但这会带来它自己的风险,尤其是在真正的浏览器上发现问题的时间比我们希望的要晚得多.

We're going to start altering our working practices to mitigate the problem, including a greater emphasis on the hosted-mode browser, which defers the need to run the GWT compiler until a later time, but that brings its own risks, particularly that of not catching issues with real browsers until much later than we'd like.

理想情况下,我们希望让 GWT 编译器本身更快 - 编译一个相当小的应用程序一分钟就是小便.但是,我们正在使用 compile 如果一种相当幼稚的方式,所以我希望我们可以快速轻松地获得一些收益.

Ideally, we'd like to make the GWT compiler itself quicker - a minute to compile a fairly small application is taking the piss. However, we are using the compile if a fairly naive fashion, so I'm hoping we can make some quick and easy gains.

我们目前正在调用 com.google.gwt.dev.Compiler 作为来自 ant Ant 目标的 Java 应用程序,具有 256m 的最大堆和大量堆栈空间.编译器由 Ant 使用 fork=true 和最新的 Java 6 JRE 启动,以尝试利用 Java6 改进的性能.我们将主控制器类与应用程序类路径一起传递给编译器,然后就可以了.

We're currently invoking com.google.gwt.dev.Compiler as a java application from ant Ant target, with 256m max heap and lots of stack space. The compiler is launched by Ant using fork=true and the latest Java 6 JRE, to try and take advantage of Java6's improved performance. We pass our main controller class to the compiler along with the application classpath, and off it goes.

我们还能做些什么来获得额外的速度?我们能不能给它更多的信息,让它花更少的时间去发现要做什么?

What else can we do to get some extra speed? Can we give it more information so it spends less time doing discovery of what to do?

我知道我们可以告诉它只为一个浏览器编译,但是我们需要做多浏览器测试,所以这不太实用.

I know we can tell it to only compile for one browser, but we need to do multi-browser testing, so that's not really practical.

此时欢迎所有建议.

推荐答案

让我们从令人不安的事实开始:GWT 编译器的性能真的很糟糕.你可以在这里和那里使用一些技巧,但你不会获得明显更好的性能.

Let's start with the uncomfortable truth: GWT compiler performance is really lousy. You can use some hacks here and there, but you're not going to get significantly better performance.

你可以做的一个很好的性能黑客是只为特定的浏览器编译,通过在你的 gwt.xml 中插入以下行:

A nice performance hack you can do is to compile for only specific browsers, by inserting the following line in your gwt.xml:

<define-property name="user.agent" values="ie6,gecko,gecko1_8"></define-property>

或在 gwt 2.x 语法中,并且仅适用于一个浏览器:

or in gwt 2.x syntax, and for one browser only:

<set-property name="user.agent" value="gecko1_8"/>

例如,这将仅为 IE 和 FF 编译您的应用程序.如果你知道你只使用特定的浏览器进行测试,你可以使用这个小技巧.

This, for example, will compile your application for IE and FF only. If you know you are using only a specific browser for testing, you can use this little hack.

另一种选择:如果您使用多个区域设置,并且再次仅使用一个进行测试,您可以将它们全部注释掉,以便 GWT 将使用默认区域设置,这会减少编译时的一些额外开销.

Another option: if you are using several locales, and again using only one for testing, you can comment them all out so that GWT will use the default locale, this shaves off some additional overhead from compile time.

最重要的是:您不会在编译器性能上获得数量级的提升,但如果稍微放松一下,您就可以在这里和那里节省几分钟的时间.

Bottom line: you're not going to get order-of-magnitude increase in compiler performance, but taking several relaxations, you can shave off a few minutes here and there.

这篇关于如何加速 gwt 编译器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆