Windows 上 jruby 下的 rspec 测试运行速度非常慢
我们正在考虑转向 jruby,作为其中的一部分,我们一直在研究测试方法和框架。我一直在本地开发机器上测试 rspec,发现使用 2 个非常简单的方法对单个类运行 2 个测试所需的总时间是 7-8 秒。简单地说,我的意思是一个 setter 和一个返回 true 的 setter。
rspec 输出显示测试运行大约需要 2 秒,因此总时间中有 5-6 秒用于加载和初始化 rspec。 从命令行运行
C:\rubycode\rspec_tutorial>rspec --profile user_spec.rb
..
Top 2 slowest examples:
User User should NOT be in any roles not assigned to it
0.023 seconds ./user_spec.rb:15
User User should be in any roles assigned to it
0.006 seconds ./user_spec.rb:10
Finished in 2 seconds
2 examples, 0 failures
我使用运行 jruby 1.6.5 和 rspec 2.7.1
我已阅读这篇文章, 使用 JRuby 加快 RSpec 但它已经超过 1.5 年了,答案与运行测试套件有关,而不是在本地短暂爆发少量测试以帮助 TDD,这就是我们想要的开发方式。接下来我们将合并一个 CI 服务器。
我的问题是,这是预期的执行时间吗?有什么方法可以加快 JRUBY 本地开发机器上 rspec 测试的运行速度吗?
编辑:
最大的性能提升是从 64 位“服务器”JVM 切换到 32 位“客户端”模式。我发现运行简单测试所需的时间减少了大约 40%。我也安装并运行了 Nailgun,但性能有所不同。 banzaiman 提供的以下链接非常有帮助
We are considering a move to jruby, and as part of this have been researching testing approaches and frameworks. I've been testing rspec on my local development machine and am finding that the total time taken to run 2 tests for a single class with 2 very simple methods is 7-8 seconds. By simple, I mean one setter and one that returns true.
The rspec output shows that the tests run in roughly 2 seconds, so 5-6 seconds of the total time is spent loading and initializing rspec. I'm running from the command line using
C:\rubycode\rspec_tutorial>rspec --profile user_spec.rb
..
Top 2 slowest examples:
User User should NOT be in any roles not assigned to it
0.023 seconds ./user_spec.rb:15
User User should be in any roles assigned to it
0.006 seconds ./user_spec.rb:10
Finished in 2 seconds
2 examples, 0 failures
I'm running jruby 1.6.5 and rspec 2.7.1
I've read this post, Faster RSpec with JRuby
but it's over 1.5 years old, and the answer relates to running suites of tests as opposed to short bursts of a small number of tests locally to aid TDD, which is how we want to develop. Down the line we'll incorporate a CI server.
My question is, is this the expected execution time? Is there any way to speed up the running of rspec tests on the local development machine uner JRUBY?
EDIT:
Biggest performance gains were switching from 64 bit "server" JVM to 32 bit "client" mode. I saw about a 40% reduction in the time taken to run a simple test. I got Nailgun up and running as well, but performance varied. The link provided below by banzaiman was most helpful
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它不是在加载 RSpec,而是您感觉到的 JVM 启动时间。
请参阅 https://github.com/jruby/jruby/wiki/Improving-startup-是时候了解更多信息了。
It is not loading RSpec, but it is JVM startup time you are feeling.
See https://github.com/jruby/jruby/wiki/Improving-startup-time for more information.