Edit: Somewhat different (and fewer) bottlenecks with Bundler 1.0.9 instead of 1.0.3.
I'm terribly annoyed by Rails's slow startup time (since I run tests repeatedly), so I'm trying to find out the culprit is using poor-man's profiling, by running rails console --help
(which loads all my gems) repeatedly, hitting Ctrl+C, and looking at the stack trace.
Apart from the obvious culprits like active_support
and friends being loaded, some of the time (perhaps 10% or so), the output looks similar to this:
$ rails console --help
^C/var/lib/gems/1.9.1/specifications/i18n-0.5.0.gemspec:3:in `new': Interrupt
from /var/lib/gems/1.9.1/specifications/i18n-0.5.0.gemspec:3:in `load_specification'
from /usr/lib/ruby/1.9.1/rubygems/source_index.rb:95:in `eval'
from /usr/lib/ruby/1.9.1/rubygems/source_index.rb:95:in `load_specification'
from /usr/lib/ruby/1.9.1/rubygems/source_index.rb:153:in `block (2 levels) in load_gems_in'
from /usr/lib/ruby/1.9.1/rubygems/source_index.rb:152:in `each'
from /usr/lib/ruby/1.9.1/rubygems开发者_StackOverflow/source_index.rb:152:in `block in load_gems_in'
from /usr/lib/ruby/1.9.1/rubygems/source_index.rb:149:in `reverse_each'
from /usr/lib/ruby/1.9.1/rubygems/source_index.rb:149:in `load_gems_in'
from /usr/lib/ruby/1.9.1/rubygems/source_index.rb:345:in `refresh!'
from /usr/lib/ruby/1.9.1/rubygems/source_index.rb:78:in `from_gems_in'
from /usr/lib/ruby/1.9.1/rubygems/source_index.rb:58:in `from_installed_gems'
from /usr/lib/ruby/1.9.1/rubygems.rb:866:in `source_index'
from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/source.rb:161:in `installed_specs'
from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/source.rb:151:in `block in fetch_specs'
from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/index.rb:7:in `build'
from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/source.rb:150:in `fetch_specs'
from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/source.rb:65:in `specs'
from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/definition.rb:159:in `block (2 levels) in index'
from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/definition.rb:158:in `each'
from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/definition.rb:158:in `block in index'
from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/index.rb:7:in `build'
from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/definition.rb:157:in `index'
from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/definition.rb:151:in `resolve'
from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/definition.rb:90:in `specs'
from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/definition.rb:135:in `specs_for'
from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/definition.rb:124:in `requested_specs'
from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/environment.rb:23:in `requested_specs'
from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler/runtime.rb:11:in `setup'
from /var/lib/gems/1.9.1/gems/bundler-1.0.9/lib/bundler.rb:101:in `setup'
from /home/jo/src/mercury/config/boot.rb:8:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from script/rails:5:in `<main>'
So it seems that quite some time is spent loading gemspecs.
Is there some way to speed this up? Dirty hacks are appreciated too -- I just want to run my test suite without (so much) delay.
have you tried spork?
Update to this: tconsole is really cool too, if you are using MiniTest.
精彩评论