如何对 Rails 3 应用程序的测试套件进行基准测试
我想优化一个测试套件。首先我需要知道时间都花在哪里了。至少我想知道每次测试花费了多少时间。
我遇到了这个 gem https://github.com/timocratic/test_benchmark
但不再维护。
请注意,我的目标是对测试套件进行基准测试,而不是对应用程序进行基准测试。
还有其他我可以使用的宝石吗?
- Rails
- Rspec
- 水豚
I want to optimise a test suite. First I need to know where the time is being spent. As a minimun I want to know how much time is spent in each test.
I came across this gem https://github.com/timocratic/test_benchmark
but is no longer maintained.
Notice that my goal is to benchmark the test suite, not the application.
Is there any other gem that I could use?
- Rails
- Rspec
- Capybara
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Rspec 包含一个最低限度的功能分析器。你看过吗? (博客文章rspec1 的教程,但对 rspec2 仍然有效)
基本上,如果您指定
-p
,那么您将获得最慢的 10 个测试的列表。Rspec has a minimum functionality profiler included. Have you looked at it? (blog post tutorial for rspec1 but still valid for rspec2)
Basically, if you specify
-p
then you get a list of the slowest 10 tests.你熟悉unix time命令吗?如果你只是想看看你的测试套件运行需要多长时间,你可以在前面添加时间命令:
在你的 rspec 输出之后,你应该看到类似的内容
当然,这是假设你在 *nix 平台上:-)
-一个
Are you familiar with the unix time command? If you're just looking to see how long your test suite took to run you can just prepend the time commmand:
After your rspec output you should see something like
Of course, this is assuming you're on a *nix platform :-)
-a