I recently switched from REE to ruby 1.9.2 and I was shocked by how
long it takes for rails to startup. This isn’t as much of an issue in
production, but in development and test environments it’s almost
unusable because it’s killing my workflow.
for example, sometimes I need to run a single test or play around in
the console. I’ve made sure I’m only loading gems I need and I’ve
switched to the RVM patched version of 1.9.2 which is a big help.
I’m also using spork for my tests. However, it still takes 20 +
seconds to load a console. Also, spork is fantastic for unit and
functional tests but can’t be used for integration tests because spork
requires config.cache_classes to be set to false, but integration
tests are painfully slow with that setting.
Is there anything else I can do to speed up the startup time,
especially in the development environment?
Hi, on my system, it takes 5 - 7 seconds to start the web server. BTW, I’m using Mac OS and thin web server. Next, I would make sure that spork is properly setup on your system. Also, if you haven’t installed autotest, then I would recommend getting this properly installed as well. If you’re using RSpec, then make sure that .rspec contains the following at an absolute minimum:
–drb
How are you running spork from the command? If you’re using bundler within your Rails project, you should be starting spark as follows:
bundle exec spork
Also, if you’re doing TDD/BDD, then you’ll be spending the majority of your time doing the following:
a) writing a failing test
b) implementing the code that makes the test pass
c) refactoring
d) goto (a)
If you’re using Rails 3, you can find an excellent walk through here for getting your environment setup.
http://ruby.railstutorial.org/chapters/static-pages#sec:TDD
Last but not least, I would check the overall performance of the underlying hardware because this can be one of the variables for contributing to the slowness within your application startup.
Good luck,
-Conrad