Rails 3 渲染速度太慢了
我最近启动了我的 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你如何渲染你的部分?开发模式下的 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!