I'm running Ruby on Rails on a 2011 Macbook Pro with 8GB of RAM. I takes 2 seconds to start rails with no options, and it takes 12 seconds to load the console. What is Rails doing in this time? I can't believe that it is taking 12 seconds. My app is not that big – 10,607 lines in the app folder.

$ time rails > /dev/null

real    0m2.830s
user    0m2.751s
sys 0m0.076s

$ time echo exit | rails console > /dev/null

real    0m12.825s
user    0m11.779s
sys 0m0.898s

I'm running Ruby 1.9.3 and Rails 3.2:

$ ruby -v
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin12.0.0]
$ rails -v
Rails 3.2.11
$ wc -l `find app -name *.rb`
10607 total

Edit:

Doing the same with an empty rails project (just rails new):

marc@menasor ~/dev/rails_empty $ time rails > /dev/null
real    0m2.192s
marc@menasor ~/dev/rails_empty $ time echo exit | rails c > /dev/null
real    0m3.807s

So that's nearly 4 seconds to start an empty rails project. What is happening for those 4 seconds?

Here is some timings for starting my original Rails project on a Macbook Air with an SSD with 4GB RAM.

$ time rails
real    0m1.161s
$ time echo exit | rails console
real    0m20.356s

So the SDD reduced rails startup time be nearly 2 seconds, so I assume that is doing a lot of IO. The time to start the rails console has gone up though.

Edit:

Adding profiling data after Reck's suggestion:

Total: 404 samples
 116  28.7%  28.7%      116  28.7% garbage_collector
  62  15.3%  44.1%      258  63.9% Kernel#require
  12   3.0%  47.0%       28   6.9% Journey::Visitors::Each#visit
  12   3.0%  50.0%       12   3.0% Regexp#===
   9   2.2%  52.2%       52  12.9% Module#class_eval
   9   2.2%  54.5%       12   3.0% Module#module_eval
   9   2.2%  56.7%        9   2.2% Modu
Edit
Report