所以我正在尝试改进我的测试执行时间,并且一直在遵循一些优秀的建议(最值得注意的是Railscasts 412)。
Zeus 似乎工作正常(除了需要您输入zeus test test
才能运行 Minitest 套件的怪异之处。)
这是 zeus 的定时输出:
基线(耙式测试):
$ time rake test
Run options: --seed 62848
# Running tests:
........
Finished tests in 0.117071s, 68.3346 tests/s, 68.3346 assertions/s.
8 tests, 8 assertions, 0 failures, 0 errors, 0 skips
real 0m5.771s
user 0m4.477s
sys 0m0.872s
和宙斯一起:
$ time zeus test test
Run options: --seed 10325
# Running tests:
........
Finished tests in 0.126365s, 63.3087 tests/s, 63.3087 assertions/s.
8 tests, 8 assertions, 0 failures, 0 errors, 0 skips
real 0m0.765s
user 0m0.209s
sys 0m0.030s
好的。5.7 秒降至 0.7 秒。
现在,有了春天,我只是没有看到第一次运行后的改进。我正在运行 Spring gem 1.1.0beta4,按描述安装(添加到 Gemfile,然后运行bundle exec spring binstub --all
)。
这就是我所拥有的:
基线,第一次执行(rake 测试):
time bin/rake test
Run options: --seed 49915
# Running tests:
........
Finished tests in 0.108359s, 73.8287 tests/s, 73.8287 assertions/s.
8 tests, 8 assertions, 0 failures, 0 errors, 0 skips
real 0m6.265s
user 0m0.072s
sys 0m0.020s
确认 spring 正在运行:
$ spring status
Spring is running:
2990 spring server | gdc4 | started 43 secs ago
2991 spring app | gdc4 | started 43 secs ago | test mode
并再次运行测试...
$ time bin/rake test
Run options: --seed 27416
# Running tests:
........
Finished tests in 0.132677s, 60.2968 tests/s, 60.2968 assertions/s.
8 tests, 8 assertions, 0 failures, 0 errors, 0 skips
real 0m3.885s
user 0m0.069s
sys 0m0.014s
所以有点加速,但仍然需要将近 4 秒才能执行。同时,顺便说一句,rails 控制台的加载速度确实快了一吨 w/ Spring ....< 1 秒。
所以,我的问题是:为什么 Zeus 能够在测试中获得数量级的加速(5.7s -> 0.7s),但 Spring 不能?
运行 Rails 4.0.2,Ruby 2.0.0 顺便说一句。