高级闭包编译器 - 有任何性能影响吗?

发布于 2024-10-17 19:46:46 字数 288 浏览 3 评论 0原文

在线闭包编译器非常棒:

http://closure-compiler.appspot.com/home

但是,当使用高级选项时,它会影响脚本的性能吗? IE,它通常会使其更快或更慢,还是取决于脚本本身?或者根本没有性能影响?

我之所以问这个问题,是因为我编写的一些脚本对性能至关重要,而且我知道这个问题的答案是“尝试看看”,但我不太擅长运行此类测试,我不知道从哪里开始。

The online closure compiler is amazing:

http://closure-compiler.appspot.com/home

However, when using the advanced option, will it affect performance of the script at all? IE, will it make it faster or slower in general, or does it depend on the script itself? Or is there no performance hit at all?

I only ask this as some scripts I write will be performance critical, and I know the answer to this question is "try and see" but I'm not very good at running these sorts of tests, I don't know where to start.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

那些过往 2024-10-24 19:46:46

以下是您可能感兴趣的闭包编译器常见问题解答中的两点。

编译器是否会在我的应用程序的执行速度和下载代码大小之间进行权衡?

是的。任何优化编译器都会做出权衡。某些尺寸优化确实会带来较小的速度开销。然而,闭包编译器的开发人员一直小心翼翼地避免引入大量额外的运行时。一些编译器的优化甚至会减少运行时间(请参阅下一个问题)。

编译器是否针对速度进行了优化?

在大多数情况下,较小的代码是更快的代码,因为下载时间通常是 Web 应用程序中最重要的速度因素。减少冗余的优化也可以加快代码的运行时间。

所以看来这取决于您编写的代码。可能会更快,但也有可能会慢一点。最终,需要进行测试。

Here are two points from the Closure Compilier faq that may interest you.

Does the compiler make any trade-off between my application's execution speed and download code size?

Yes. Any optimizing compiler makes trade-offs. Some size optimizations do introduce small speed overheads. However, the Closure Compiler's developers have been careful not to introduce significant additional runtime. Some of the compiler's optimizations even decrease runtime (see next question).

Does the compiler optimize for speed?

In most cases smaller code is faster code, since download time is usually the most important speed factor in web applications. Optimizations that reduce redundancies speed up the run time of code as well.

So it would seem that it will depend on the code you've written. Could be faster, but there's a chance it could be a little slower. Ultimately, testing will be required.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文