开发者

If a Rails app uses "require 'gem_name'" instead of "gem 'gem_name'" or "config.gem 'gem_name'", will it be faster?

because

gem 'gem_name'          # Rails 3.0

or

config.开发者_如何学运维gem 'gem_name'   # Rails 2.x

will load the gem no matter what the controller is... will a

require 'gem_name' 

in the controller source code actually make the Rails server run faster because not every controller will load that gem?


The short answer is: no.

Stick with keeping your code sane and maintainable by grouping your required gems in your Gemfile / environment.rb.

I would need to see some well crafted performance data before I'd believe that this would ever make a noticeable difference in a production environment. There are so many other places to optimize first.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜