Here’s a simple script I wrote to benchmark the loading of each of the gems in
your Gemfile. A gist can be found here.
All of the code in #pull has been plucked right out of the
Bundler require function. It’s responsible for loading
a gem depending on its Gemfile configuration. It considers custom require paths,
and generally converts dashes into slashes if it can’t load the file.
The script then loads rails (require 'rails/all') - something you won’t be
able to avoid either way. It also turns warnings off ($VERBOSE = nil) so that
the benchmarking output looks a little nicer.
Once that setup is complete, it loops through each of the gem dependencies and
requires them. Your output will probably look something like this:
I’ve condensed the output, but the total load time was 5 seconds. You can verify
that by benchmarking Bundler.require in your own application. You’ll also
notice that the declarative authorization gem took up approximately 1 second
(20% of the total time) to load. Maybe it’s a good candidate for an upgrade,
replacement or optimization.