6

所以我正在尝试改进我的测试执行时间,并且一直在遵循一些优秀的建议(最值得注意的是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 顺便说一句。

4

4 回答 4

3

你不能跑

耙式试验

你需要跑

弹簧耙试验

例子:

时间耙-T

10.737s

时间耙-T

10.811s # 没有改善,正如你所说

时间弹簧耙-T

18.468s

时间弹簧耙-T

1.140s # 巨大的改进

于 2014-03-28T20:04:36.687 回答
0

我只玩过一点 spring 并且没有将时间与 zeus 进行比较(我更喜欢),但我的猜测是你仍然看到 spring 本身的缓慢 [ruby] 启动时间。Zeus 没有任何这些,因为它是用 Go 编写的。

于 2014-03-22T16:08:45.667 回答
0

我在这里看到了同样的区别。例如运行 rails 服务器:with zeus < 1s with spring ~ 4s

于 2014-04-04T07:11:45.820 回答
0

可能是因为zeus test没有运行db:reset

在我的一个应用程序中,Spring 在 5-6 秒内运行测试,而 Zeus 在大约 0.5 秒内运行它们,这肯定是由于 Spring 每次都重新加载数据库。

于 2016-10-29T15:43:07.077 回答