简体   繁体   English

如何在Windows上的rails测试中加速ruby?

[英]how can I speed up ruby on rails tests on windows?

I've started learning to use Ruby on Rails running on Windows 7, and the time to run tests is painful I'm wondering if I can speed it up. 我已经开始学习在Windows 7上运行Ruby on Rails了,运行测试的时间很痛苦,我想知道我是否可以加快速度。 Right now I am using the default test framework (inheriting from ActionController), with a SQLite database and the webrick web server. 现在我正在使用默认测试框架(继承自ActionController),使用SQLite数据库和webrick Web服务器。

While unit and functional tests report a runtime of less than 2 seconds, from the time I run the tests from the command-line to completion is actually 40 secounds. 虽然单元和功能测试报告的运行时间不到2秒,但从我从命令行运行测试到完成的时间实际上是40秒。

A friend recommended I use guard. 朋友推荐我使用后卫。 That looks like it will help start the tests as soon as I save, but it seems like the real cost is starting up the webserver or database. 看起来它有助于我保存后立即开始测试,但似乎真正的成本是启动网络服务器或数据库。 I wonder if it might be better to set up apache or mysql and use those locally instead. 我想知道是否可能更好地设置apache或mysql并在本地使用它们。

Anyhow, what tips do people have for speeding up ruby on rails tests on windows? 无论如何,人们有什么技巧可以在Windows上的轨道测试中加速ruby? I tried running the tests on Amazon EC2 linux micro instance (again with webrick and sqlite) and there was significant startup time (though I did not time it). 我尝试在Amazon EC2 linux微实例上运行测试(再次使用webrick和sqlite)并且有很长的启动时间(尽管我没有时间)。

I tried "rake test --trace". 我试过“rake test --trace”。 There was a significant pause: 有一个显着的停顿:

  • Immediately before the first line of output 紧接在第一行输出之前
  • Between outputing "Execute environment" and "Execute db:abort_if_pending_migrations" 在输出“执行环境”和“执行数据库:abort_if_pending_migrations”之间
  • Between "Execute test:units" and "Run options:" 在“执行测试:单位”和“运行选项:”之间

    The first pause seems worse. 第一次停顿似乎更糟。

Your best bet is to use spork which now works in Windows. 您最好的选择是使用现在可在Windows中运行的spork It runs on windows by pre-populating a pool of ready processes (referred to as the “magazine” strategy). 它通过预先填充一系列现成的流程(称为“杂志”策略)在Windows上运行。 The result is that webserver startup time is dramatically reduced. 结果是网络服务器启动时间大大减少。

If running rails on Windows is really the bottleneck then you can run a virtual machine using VirtualBox and run an instance of Ubuntu and work on your rails projects in the VM. 如果在Windows上运行rails确实是瓶颈,那么您可以使用VirtualBox运行虚拟机并运行Ubuntu实例并在VM中处理rails项目。

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

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