Rails 3 - Speed up Console Loading Time

后端 未结 6 1725
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-02 07:55

I am wondering if there is any relatively easy way to speed up my console load time, which is starting to approach 30 seconds. I have a lot of subclasses whose methods don\

6条回答
  •  情歌与酒
    2020-12-02 08:32

    Slightly adapted form that is copy-pastable, wraps all requires, and provides sortable output:

    # Add this to the top of boot.rb
    require 'benchmark'
    def require(file)
      puts Benchmark.measure("") {
        super
      }.format("%t require #{file}")
    end
    

    Then you can execute no-op to see them:

    rails runner 1
    

    Or sort them and show the top 50:

    rails runner 1 | sort -nr | head -n 50
    

提交回复
热议问题