简体   繁体   English

Ruby/Rails 在 Windows 上运行缓慢 7

[英]Ruby/Rails running slow on Windows 7

I know this is a common topic for questions but I couldn't find any that seemed to answer my question which seemed a little different than most with this topic.我知道这是一个常见的问题主题,但我找不到任何似乎可以回答我的问题的问题,这似乎与该主题的大多数问题有所不同。

I'm new to Ruby and Ruby on Rails so keep that in mind with this question.我是 Ruby 和 Ruby on Rails 的新手,所以在回答这个问题时请记住这一点。 Whenever I run bundle, rails, etc. commands either through my IDE (Aptana) or in the Windows command screen, they literally take up to a minute to execute.每当我通过我的 IDE (Aptana) 或在 Windows 命令屏幕中运行 bundle、rails 等命令时,它们实际上需要一分钟的时间来执行。 A bundle install can take 20 seconds to begin printing anything to the screen, rspec commands can take 40 seconds to begin before taking 6 seconds to run tests (an appropriate time for this case).捆绑安装可能需要 20 秒才能开始在屏幕上打印任何内容,rspec 命令可能需要 40 秒才能开始,然后需要 6 秒才能运行测试(对于这种情况来说是合适的时间)。 Rails server can take 40 seconds to start. Rails 服务器可能需要 40 秒才能启动。

It wasn't always this way but somewhere along the way of updating gems, installing newer stuff, getting Aptana IDE, it hit the fan.它并不总是这样,但在更新 gems、安装更新的东西、获取 Aptana IDE 的过程中,它很受欢迎。

Any ideas how to get the wrench out the engine?任何想法如何将扳手从发动机中取出? Thanks.谢谢。

I'm not an expert on Win7, but I would suggest checking your system memory and cpu usage.我不是 Win7 专家,但我建议检查您的系统 memory 和 cpu 使用情况。 See if there is a bottle neck.看看有没有瓶颈。

Also, at the very least, make sure you're running the latest version of Bundler.另外,至少要确保您运行的是最新版本的 Bundler。 Up until fairly recently it's version was 1.0.x.直到最近它的版本是 1.0.x。 It recently went to 1.1 and is now at 1.1.3 with the major change being how long it too to walk the dependency tree among gems.它最近达到了 1.1,现在是 1.1.3,主要变化是在 gems 之间遍历依赖树的时间也很长。

Also, I too use Windows 7 for Ruby in some situations.此外,在某些情况下,我也将 Windows 7 用于 Ruby。 I also found that installing "thin" as your Rails web server ( C:\ gem install thin ) will perform much faster than the default WEBrick server.我还发现安装“thin”作为 Rails web 服务器 ( C:\ gem install thin ) 将比默认的 WEBrick 服务器执行得更快。

If you these two things, I think you'll notice a performance increase.如果你做这两件事,我想你会注意到性能提升。

As far as your tests go, if you're using RSpec..that's just the nature of the beast.就您的测试 go 而言,如果您使用的是 RSpec.. 那只是野兽的本性。

I am using Ruby 1.9.3p392, Rails 3.2.13.我正在使用 Ruby 1.9.3p392,Rails 3.2.13。 The project connects to a mysql database.该项目连接到 mysql 数据库。

  • tried it on Window 7 - server takes 10s to startup, rendering a login page takes over 1 minute.在 Window 上试过 7 - 服务器启动需要 10 秒,呈现登录页面需要 1 分钟以上。
  • tried it on ubuntu 12.10 virtual machine on virtualbox - twice as worst在 virtualbox 上的 ubuntu 12.10 虚拟机上试过 - 最差的两倍
  • tried it on ubuntu 12.10 virtual machine on VMWare player - much better, almost on par with Windows 7.在 VMWare 播放器上的 ubuntu 12.10 虚拟机上试过 - 好多了,几乎与 Windows 7 相当。

So I bite the bullet and setup a dual boot linux-mint system, and the problems go away.所以我硬着头皮设置了一个双引导 linux-mint 系统,问题 go 消失了。 So the problem lies with some low level system api that even a virtual machine is dependent on.所以问题出在一些低级系统 api 上,甚至虚拟机都依赖它。

There are other problems with using Windows as well, for example many gems are not compiled for windows (like therubyracer and imagemagic), so you need to jump through the loop to get them to work.使用 Windows 也有其他问题,例如许多 gem 不是为 windows 编译的(比如 therubyracer 和 imagemagic),所以你需要跳过循环才能让它们工作。

So in conclusion, forget about Windows for RoR development.所以总而言之,忘记 Windows 进行 RoR 开发。 But seriously, if RoR is made more Windows friendly, I am certain it will be quite a lot more popular.但说真的,如果 RoR 变得更 Windows 友好,我相信它会更受欢迎。 I almost gave up in the process, and it remain a real pain for me having to switch between Windows and Linux every so often.我几乎在这个过程中放弃了,而且我不得不经常在 Windows 和 Linux 之间切换,这仍然是一个真正的痛苦。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM