Skip to content

Instantly share code, notes, and snippets.

@matisojka
Created July 4, 2012 07:05
Show Gist options
  • Save matisojka/3045819 to your computer and use it in GitHub Desktop.
Save matisojka/3045819 to your computer and use it in GitHub Desktop.
Measure Gem loading time in your Rails APP
# Disclaimer: this solution has been taken from the post: http://stackoverflow.com/a/5071198/784270
# navigate to the bundler gem and in lib/bundler/runtime.rb,
# find the line that does Kernel.require and wrap it like this
puts Benchmark.measure("require #{file}") {
Kernel.require file
}.format("%n: %t %r")
# Add
require 'benchmark'
# to config/boot.rb
# Start the console / server to see the benchmark.
# If you want to measure the total loading time of your Rails app, you can use the solution
# proposed in: http://erik.debill.org/2011/02/19/ruby-start-up-times
echo puts Time.now > test_script
time rails runner test_script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment