问题描述
为什么 Ruby 和 Ruby on Rails(1.8.6 一键安装程序,本地数据库)在 Windows 上如此缓慢?
Why is Ruby, and Ruby on Rails (1.8.6 One Click Installer, local database) so ruddy slow on Windows?
- ruby 脚本/服务器 - 30 秒
- rake 测试 - 45 秒
- 等
然而,当我跳到一个速度慢得多的 linux 机器时,它几乎是瞬间完成的.我已经检查了所有内容 - 没有重要的 CPU 进程在运行,没有网络问题......等等.
Yet, when I pop over to a much slower linux box, it's virtually instantaneous. I've checked everything - no significant CPU processes running, no network issues... and so on.
哎呀,我很高兴看到一个详细的输出,至少告诉我它在哪里崩溃了.有什么建议吗?
Heck, I'd be happy with just a verbose output that at least told me where it was breaking down. Any suggestions?
推荐答案
总的来说,Ruby 的 MRI 解释器并未针对 Windows 上的速度进行优化.您也可能在 Windows 上以开发模式运行它,而在其他机器上以生产模式运行它.Rails 在开发模式下运行速度要慢得多,因为它会根据每个请求重新加载所有类.
In general Ruby's MRI interpreter is just not optimized for speed on windows. You might also be running it in development mode on windows vs production mode on the other machines. Rails runs much slower in development mode since it reloads all your classes on every request.
1.8.6 是一个非常古老的 ruby 版本.大约 3 年前发布.您应该强烈考虑升级到 1.9(或至少 1.8.7).或者切换到 JRuby.所有这些选项都可能会显着提高性能.
1.8.6 is a very old ruby version. Released almost 3 years ago. You should strongly consider upgrading to 1.9 (or at least 1.8.7). Or switching to JRuby. All of these options will likely lead to a significant performance improvement.
1.8.7 应该与 1.8.6 完全兼容.1.9 有一个全新的解释器,运行速度提高 2.5 倍(尽管它偶尔会在 Windows 上崩溃).JRuby 可能是您的理想解决方案,因为您可以在兼容 1.8 或 1.9 的情况下运行它,而且它非常稳定,但它不支持带有 C 扩展的 gem,并且需要不同的数据库适配器.
1.8.7 should be fully compatible with 1.8.6. 1.9 has a completely new interpreter that runs 2.5 times faster (Though it has a tendency to occasionally crash on windows). JRuby may be the ideal solution for you since you can run it in either compatibility for 1.8 or 1.9 and it is very stable, but it does not support gems with C extensions and requires a different database adapter.
最后一个选择是尝试在装有 CentOS 或其他 Linux 发行版的 VMWare 中运行 Rails.
One last option would be to try running Rails inside of a VMWare with CentOS or another Linux distribution.
这篇关于Windows 中的 Rake 测试非常慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!