有什么提示和建议吗?让犀牛表现更快的技巧?
有什么提示和建议吗?让犀牛表现更快的技巧?我正在尝试在Rhino中使用uglifyJs压缩一个大的js文件,这需要一分多钟的时间。您对 java 服务器端空间中的 rhino 有任何提示或其他替代方案吗?
Are there any tips & tricks for making rhino perform faster? I'm trying to compress a large js file using uglifyJs in Rhino and it takes more than a minute. Do you have any hints or other alternatives for rhino in java server side space?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通过 Rhino 上的 JavaScript API,您可以使用
Compilable
接口简单地编译脚本。例如:但是,当多次运行脚本时,这样做的好处就会显现出来。基本上它减少了每次重新解释的开销。来自
CompiledScript
javadoc:无论如何,我认为你应该看看 Rhino JavaScript 编译器。它“将 JavaScript 源代码转换为 Java 类文件”。
并且有一个 V8 Java 实现。检查 jav8。
With the JavaScript API over Rhino you can simply compile the script using the
Compilable
interface. For example:However the benefits of this will show up when running several times the script. Basically it reduces the overhead of re-interpret every time. From the
CompiledScript
javadoc:Anyway I think you should take a look at the Rhino JavaScript Compiler. It "translates JavaScript source into Java class files".
And there is a V8 Java implementation. Check jav8.
v8
或者尝试使用“编译”模式而不是“解释”模式。
v8
or try to use "compiling" mode instead of "interpreting" mode.