[英]Rake tests running very slow
After running some tests, I'm convinced there has to be something wrong with my setup (windows, rubymine and latest ruby versions). 经过一些测试后,我确信我的设置(窗口,rubymine和最新的ruby版本)都有问题。 My times right now are:
我现在的时代是:
Finished tests in 14.289817s, 0.0700 tests/s, 0.3499 assertions/s.
1 tests, 5 assertions, 0 failures, 0 errors, 0 skips
Process finished with exit code 0
With 5 VERY easy tests (just checking if validation on empty fields works). 有5个非常简单的测试(只检查空字段上的验证是否有效)。 The total time for these 5 unit tests is 160 seconds, over 2 minutes.
这5个单元测试的总时间为160秒,超过2分钟。
What could I do to improve this speed? 我该怎么做才能提高这个速度?
Here are the tests: 以下是测试:
require 'test_helper'
class ItemTest < ActiveSupport::TestCase
test 'item attributes must not be empty' do
item = Item.new
assert item.invalid?
assert item.errors[:name].any?
assert item.errors[:description].any?
assert item.errors[:image_url].any?
assert item.errors[:rating].any?
end
end
Your problem is Windows. 你的问题是Windows。 We use JRuby on Windows and it actually runs faster than RubyInstaller(mingw) ruby on Windows but we do see very slow results when running test suites or starting a rails server.
我们在Windows上使用JRuby,它实际上比Windows上的RubyInstaller(mingw)ruby运行得更快但是在运行测试套件或启动rails服务器时我们确实看到非常慢的结果。 About 1 minute for a single test run due to the loading of the Rails environment.
由于加载了Rails环境,单次测试运行大约需要1分钟。 You have a few options:
你有几个选择:
Good luck! 祝好运!
What's the rest of your gem stack? 什么是你的宝石堆栈的其余部分? Sometimes third-party gems are initialized by rails and will try to phone home (New Relic, Airbrake) which can inflate your test times (though probably not by this much).
有时第三方宝石由rails初始化并将尝试打电话回家(New Relic,Airbrake),这可能会使你的测试时间膨胀(尽管可能不是这么多)。 If something isn't strictly required for your test suite, you should try to pull it into the proper env group, or set
require :false
via bundler: 如果您的测试套件没有严格要求的东西,您应该尝试将其拉入正确的env组,或通过bundler设置
require :false
:
group :production do gem 'newrelic_rpm' end
Startup time appears to be killing you, so you and I are probably in the same boat. 启动时间似乎在扼杀你,所以你和我可能在同一条船上。 Between Jodell and Dark Castle a lot of this is covered already, but here's my nearly-whole list of things that helped, in descending order of efficacy.
在Jodell和Dark Castle之间已经有很多这方面的内容了,但是这里有几乎所有有用的东西,按功效降序排列。
set SPEC_OPTS=--drb
set SPEC_OPTS=--drb
6 didn't actually buy me very much. 6实际上并没有给我买单。 The biggest thing we had wrong was loading Thin unconditionally (which pulls in Eventmachine, which 21 megabytes installed), but the next 3 on the stack were actually being used by RSpec.
我们遇到的最大问题是无条件地加载Thin(它安装了Eventmachine,安装了21兆字节),但是堆栈中接下来的3个实际上正被RSpec使用。 I have not looked at network traffic, but Jodell is probably on to something there.
我没有看过网络流量,但Jodell可能正在那里。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.