You can clone with
Rails boot-up time is a hot topic these days, and I got curious why my small application was taking a long time to start on Rails 3.1 and Ruby 1.9.3. I tried running time rails r 1 repeatedly, each time adding gems to or trimming gems from Gemfile to see their relative impact, and it seems that capybara is a worse offender than most, weighing in around a cost of around 0.4 seconds on my fairly old machine. Is there anything obvious which can be done to improve this?
time rails r 1
If you're just worried about bootup time for your unit specs (which should never need capybara), put :require => false after the gem 'capybara' bit in your gemfile.
:require => false
I don't think there is. And 0.4s on an old machine in Ruby land ain't half bad.
Hmm. My tiny Rails app has about 100 gems. If every gem took 0.4s to load, that would be a start-up time of 40s. And my "old" machine is still a dual-core 2.2GHz, so unless each gem is contributing CPU cycles to the SETI project on boot, I really can't see any justification for the slowness ;-) Maybe the problem is with Ruby itself.
However I appreciate that we all have limited time, so until I am able to do some profiling and help fix this, I won't complain about it any more ;-)
I agree it's important that gems load up fast. That said, as Jonas pointed out, there's no really obvious way to make it faster. Capybara should normally only be added to the :test group, so there's not that much point in lazy-loading Capybara, since you are probably going to use it anyway. Also, the selenium-webdriver hog is already lazy-loaded -- it loads only when a test actually uses the Selenium driver (as I just verified). So I can't think of a really easy way to improve performance.
I'm sure Jonas would be receptive to pull requests though, if you want to tackle bootup performance.
@aspiers 40s seems about right to boot a large rails app these days. Man, and the early days of rails there was lots of crowing about rails booting faster than java. lulz
@joliss The way to improve performance is to profile and find out wtf it's using several million CPU cycles just to start up ;-) I mean, what can it really need to do which requires all that work?
@tcrayford 40s may be a standard boot-up time these days, but that doesn't mean it's right, it just means that as a community we're getting sloppy and our expectations are too low ;-) You only need to look at what programmers used to do with 64k of RAM and a 50MHz CPU to be reminded of that. Or what Google achieved with Go's compilation times. Anyway, I do not want to turn this issue into a nostalgia-fest or flame war, so let's not discuss further until someone has done some profiling or coding ;-)