为什么我使用 Guard 时的速度这么慢?
当我仅使用 spork
运行我的规范时,我获得了相当显着的性能提升
$ time rspec .
.....
Finished in 11.39 seconds
5 examples, 0 failures
real 0m11.780s
user 0m10.318s
sys 0m1.180s
,并且使用 spork
$ time rspec . --drb
.....
Finished in 107.24 seconds
5 examples, 0 failures
real 0m1.968s
user 0m0.488s
sys 0m0.095s
确实很棒。但一旦我投入了后卫,一切似乎都运行得很慢,就好像根本没有勺子一样。
$ guard
Guard is now watching at '/Users/darth/projects/scvrush'
Starting Spork for RSpec
Using RSpec
Preloading Rails environment
Loading Spork.prefork block...
Spork is ready and listening on 8989!
Spork server for RSpec successfully started
Guard::RSpec is running, with RSpec 2!
Running all specs
.....
Finished in 10.77 seconds
5 examples, 0 failures
即使我不看在 10.77 秒内完成
,每次尝试运行规范时我都可以算出至少 6-8 秒,即使只是一个模型。
我对 Guardfile 做了一些小幅编辑,例如 :wait => 120
,但这应该只影响 guard
启动时。
When I run my specs using just spork
, I get quite a significant performance increase
$ time rspec .
.....
Finished in 11.39 seconds
5 examples, 0 failures
real 0m11.780s
user 0m10.318s
sys 0m1.180s
and with spork
$ time rspec . --drb
.....
Finished in 107.24 seconds
5 examples, 0 failures
real 0m1.968s
user 0m0.488s
sys 0m0.095s
which is really awesome. But once I put guard into play, it seems that everything runs so slow, as if there was no spork at all.
$ guard
Guard is now watching at '/Users/darth/projects/scvrush'
Starting Spork for RSpec
Using RSpec
Preloading Rails environment
Loading Spork.prefork block...
Spork is ready and listening on 8989!
Spork server for RSpec successfully started
Guard::RSpec is running, with RSpec 2!
Running all specs
.....
Finished in 10.77 seconds
5 examples, 0 failures
even if I don't look at the Finished in 10.77 seconds
, I can count at least 6-8 seconds every time it tries to run a spec, even for just one model.
I did some minor edits to the Guardfile, such as :wait => 120
, but that should only affect when guard
is starting up.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须在 Guardfile 中为 rspec 传递 --drb 选项,如下所示:
You have to pass the --drb option for rspec in your Guardfile, like this: