用于性能基准测试的 Rails gem/工具?

发布于 2024-10-14 16:50:58 字数 190 浏览 2 评论 0原文

我正在寻找用于监视/测试 Rails 性能的工具,但我没有太多运气找到任何特别有效的东西。我已经阅读了 Rails 的“性能”指南,但我使用 RSpec 而不是 Rake:Test,所以我并不是特别热衷于使用 rake:test 框架。

那么,除了 rake:test 基准测试程序之外,人们还使用什么来进行 Rails 性能测试呢?任何建议表示赞赏

I'm looking for tools to monitor/test performance in rails, and I'm not having much luck finding anything particularly effective. I've read the rails 'performance' guide, but I use RSpec instead of Rake:Test, so I'm not particularly keen to use the rake:test framework.

So, what do folks use for performance testing in rails apart from the rake:test benchmarker? Any suggestions appreciated

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

∞觅青森が 2024-10-21 16:50:58

性能基准测试是你会得到不同意见的事情之一,具体取决于你问的是谁。我反复听到的一件事是,你不应该一开始就过分关注性能。我不确定你的申请进展如何,但这可能是值得考虑的事情。在开发了一个相当大的应用程序之后,我可以诚实地说我同意他们的观点。最好在开发时使用良好的实践,并等待稍后进行性能调整。最佳实践包括索引数据库列之类的内容。

对于实时 Rails 应用程序的性能监控,New Relic 是最好的工具之一*。免费计划有一点限制,因为它只提供 30 分钟的历史数据,但它收集的信息是无价的。 Heroku 和 Engine Yard 等一些云主机提供免费的青铜计划升级,可存储一周的数据。一旦您掌握了有关您的申请的信息,您就可以就将时间集中在哪里做出明智的决定。

* 我的意见

Performance benchmarking is one of those things that you'll get different opinions about depending on who you ask. One thing I hear over and over is that you shouldn't obsess over performance early on. I'm not sure where you're at with your application, but this could be something to consider. After developing a rather large application, I can honestly say I agree with them. It's better to use good practice when developing and wait to do performance tuning at a later time. Best practices include things like indexing database columns.

For performance monitoring of live Rails applications, New Relic is one of the best tools out there*. The free plan is a little limited as it only provides 30 minutes of historical data, but the information it collects is priceless. Some of the cloud hosts like Heroku and Engine Yard are offering free bronze plan upgrades, which stores a week of data. Once you have information about your application, you can make educated decisions about where to focus your time.

* My opinion

星星的軌跡 2024-10-21 16:50:58

您的应用需要进行一些性能测试时,基于默认 TestUnit 的性能基准测试是一个很好的开始。但是,您不应该就此止步,而应该根据应用程序的性质考虑使用各种工具。

例如,使用 request-log-analyzer 等工具分析生产日志是一个很好的选择方法来识别真正的性能瓶颈。 Bullet 是另一个很棒的工具,您可以在开发环境中运行它来识别数据库调用中的性能低效问题。对于低级基准测试,rails 还为您提供了模型、控制器中的基准测试辅助方法和意见。如果您专注于调整应用程序的某些特定部分,这会很方便。

还值得注意的是,rspec 并不是(迄今为止)性能基准测试的最佳工具。在我看来,尝试断言诸如 it Should_take_less_than 50 之类的东西正在扩展性能测试的理念,并试图将其强行纳入 BDD 的概念中。性能通常与绝对期望无关,而更多地与识别应用程序中最慢的部分并使它们更快有关。

有许多关于该主题的在线资源。我发现这些 Railscasts 是一个很好的起点:

When your app needs some performance testing, the default TestUnit based performance benchmarking tests are a great start. However, you shouldn't stop there, and should consider using a variety of tools based on the nature of your application.

For example, analyzing production logs using a tool like the request-log-analyzer is a great way to identify the real performance bottlenecks. Bullet is another great tool you can run in your development environment to identify performance inefficiencies in your database calls. For low level benchmarking, rails also gives you the benchmark helper methods in models, controllers and views. This can be handy if you are focusing on tuning some specific part of your application.

It is also worth noting that rspec is not the best tool for benchmarking performance (to date). In my opinion, trying to assert things like it should_take_less_than 50 is stretching the idea of performance testing and trying to force it into the concept of BDD. Performance is less often about absolute expectations and more about identifying the slowest parts of your app and making them faster.

There are many online resources on the topic. I've found these railscasts to be a great starting point:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文