编译ruby脚本以加快使用速度
我有一个大约 2200 行的 ruby 脚本,正在重复使用,所以有没有办法将其转换为二进制或编译它,以便它运行得更快。
I have a ruby script of around 2200 lines which is being used repeatedly, so is there a way to convert it into binary or compile it so it runs faster.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
似乎只有 JRuby 有编译器,如果 Java 是您的目标平台并且如果没有就没有帮助。
也许您可以重新构建您的解决方案,将 Ruby 解释器包含在 管道 中,这样您的脚本可以启动一次并在收到输入时持续运行?
It seems that only JRuby has a compiler which is good news if Java is your target platform and no help if not.
Perhaps you could re-architect your solution to include the Ruby interpreter in a pipeline so that your script can be launched once and run continually as it receives input?
如果您使用 MRI,最好的选择是优化您的代码,因为 JIT 编译已经完成提供经过验证的性能。您还可以切换到 1.9 版本,因为它在各种情况下速度更快。
If you are using MRI, your best bet is to optimize your code as the JIT compilation already delivers proven performance. You can also switch to 1.9 version as it is faster in various cases.