Skip to content

Instantly share code, notes, and snippets.

@iain
Created January 9, 2012 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iain/1584310 to your computer and use it in GitHub Desktop.
Save iain/1584310 to your computer and use it in GitHub Desktop.
Logging Rails Loading Times
# Start tracking how much time you lose by loading Rails constantly
# by adding a couple of lines to config/environment.rb
# The first one is on top, the rest at the bottom of the file...
start_time = Time.now
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
YOUR_APPLICATION_NAME::Application.initialize!
loading_time = Time.now - start_time
puts "Loaded Rails in %.3f seconds" % loading_time
File.open(File.join(ENV['HOME'], "rails-load-times.csv"), "a") do |f|
f.puts "#{loading_time}, #{start_time}, #{Rails.version}, #{RUBY_VERSION}, #{Rails.root}, #{Rails.env}, #{([$0]+ARGV).join(' ')}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment