开发者

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

开发者 https://www.devze.com 2023-01-21 05:40 出处:网络
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

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

精彩评论

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