Rails:使用 RSPec 进行性能基准测试
我刚刚从 rake:test 接触到 RSpec,并且正在努力寻找任何与 rake test:benchmark 和/或 rake test:profile 等效的东西。
那么,大多数 rspec 人们使用什么来进行性能测试呢?我找到了 --profile,它返回了十个最慢的测试,但我希望有更全面的东西。
干杯...
I'm just coming across to RSpec from rake:test, and I'm struggling to find any equivalent to rake test:benchmark and/or rake test:profile.
So, what do most rspec folks use for performance testing? I've found --profile, which spits back the ten slowest tests, but I was hoping for something a little more comprehensive.
Cheers...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Diaspora 项目采用了一种有趣的方法来使用 rspec 进行性能测试 - 测试表明“此方法应该很快/花费的时间少于 N 毫秒”
https://github.com/diaspora/diaspora/blob/a6f8b2c14ed7ec13f2ecd113ae809a072814ab50/spec/controllers/aspects_controller_spec.rb#L92
与典型方法不同,但无需任何操作即可实现半生不熟的 rspec 插件
The Diaspora project took an interesting approach to performance testing with rspec -- tests that say "this method should be fast / take less than N ms"
https://github.com/diaspora/diaspora/blob/a6f8b2c14ed7ec13f2ecd113ae809a072814ab50/spec/controllers/aspects_controller_spec.rb#L92
Different than the typical approach but implementable without any half-baked rspec plugins
有 rspec-benchmark ruby gem,它允许以干净且可读的方式测试性能
:还可以指定运行代码的次数来衡量性能:
There is rspec-benchmark ruby gem which allows to test the performance in the clean and readable way:
You can also specify the number of times to run your code to measure performance: