Rails 3 渲染速度太慢了

发布于 2024-11-24 03:18:51 字数 245 浏览 4 评论 0原文

我最近启动了我的 Rails 项目的旧版本,该项目使用 Rails 2.3.11,并意识到 Rails 2.3 运行与最新版本几乎相同的代码要快得多。

我的问题:Rails 3 比 Rails 2 慢吗?特别是在渲染大量部分时?旧版本的请求从未真正超过 300 毫秒,Rails 3 需要 600 毫秒甚至更多,有时甚至需要 2 秒。有已知的解决方法吗?或者我应该将我的部分移到辅助方法中(生成 html)?不,降级不是一个选择!

问候,马里奥

I recently booted up an old version of a Rails project of mine, which uses Rails 2.3.11 and realized that Rails 2.3 is much faster running almost the same code as the recent version.

My question: Is Rails 3 slower than Rails 2? Especially when rendering lots of partials? The old version never really exceeded 300ms for a request, Rails 3 takes 600ms and more, sometimes even 2 seconds. Any workarounds known? Or should I move my partials into helper methods (generating the html)? And no, downgrading is not an option!

Greetings, Mario

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

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

发布评论

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

评论(1

时光是把杀猪刀 2024-12-01 03:18:51

你如何渲染你的部分?开发模式下的 Rails 可能会非常慢。您可以尝试将其添加到您的 Gemfile 中来尝试一下这个 gem: gem 'rails-dev-boost', :git =>; 'git://github.com/thedarkone/rails-dev-boost.git', :require => 'rails_development_boost'

如果您通过集合运行部分,则始终可以执行类似 <%= render @posts %> 的操作以获得更好的性能提升。

希望这有帮助!

How are you rendering your partials? Rails in development mode can be quite slow. You can try giving this gem a try by adding this to your Gemfile: gem 'rails-dev-boost', :git => 'git://github.com/thedarkone/rails-dev-boost.git', :require => 'rails_development_boost'.

If you are running your partials via a collection, you can always do something like <%= render @posts %> for better performance gains.

Hope this helps!

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