Rspec 更快,但在 Spork 上仍然很慢
我的规范(仅 1 个测试)使用 rspec 运行大约需要 40 秒。我现在运行了 spork,它确实将时间缩短到了大约 17 秒,但对于仅 1 次测试来说,这似乎仍然有点荒谬。我使用的是 AMD Athlon II X2 250 3.0GHz 处理器、Ubuntu 11.04、4GB RAM。在运行测试时,处理器看起来确实在短时间内两个核心都达到了 100%。这一切听起来正常还是有什么奇怪的事情发生?
此外,当通过 Guard 运行此操作时,计时器永远不会重置。所以第一个测试报告 17 秒,那么如果我在开始下一个测试之前等待 15 秒,17 秒后它将报告第二个测试花了 49 秒(第一个测试 17 秒 + 中间 15 秒 + 第二个测试 17 秒)。这是正常的吗?
describe "CompanyCustomers" do
it "allows creation of new customers" do
visit new_company_customer_path
fill_in "company_customer_first_name", :with => "John"
fill_in "company_customer_last_name", :with => "Doe"
click_button("Save")
page.should have_content("John Doe")
end
end
My spec (only 1 test) was taking about 40 seconds to run with rspec. I have spork running now and it did cut the time to about 17 seconds, but that still seems to be a little ridiculous for only 1 test. I am on an AMD Athlon II X2 250 3.0GHz processor, Ubuntu 11.04, 4GB RAM. The processor does look like it hits 100% on both cores for a brief period while running the tests. Does this all sound normal or have is there something weird going on?
Additionally, when running this through Guard, the timer never resets. So the first test reports 17 seconds, then if I wait 15 seconds before starting the next test, 17 seconds later it will report that the second test took 49 seconds (17 for the first + 15 in between + 17 for the second). Is this normal?
describe "CompanyCustomers" do
it "allows creation of new customers" do
visit new_company_customer_path
fill_in "company_customer_first_name", :with => "John"
fill_in "company_customer_last_name", :with => "Doe"
click_button("Save")
page.should have_content("John Doe")
end
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这将修复计时器,直到 Guard 或 RSpec 团队修复该问题。
不,这对于一项测试来说时间太多了。使用该代码并让我知道时间是否更真实。
如果仍然超过 10 秒,您应该尝试模仿实际代码中的操作。在浏览器中自己做。管制员需要这么长时间才能做出反应吗?也许你需要在那里优化。
如果没有,请向我们展示您的spec_helper。
This will fix the timer, until the Guard or RSpec team fixes that.
And no, that's way too much time for one single test. Use that code and let me know if the time seems more real.
If it is still over 10 seconds you should try to mimic what you do in code in real. Do it yourself in the browser. Does it take so such a long time for the controllers to respond? Maybe you need to optimise there.
If not, then show us your spec_helper.