Created
January 9, 2012 18:48
-
-
Save iain/1584310 to your computer and use it in GitHub Desktop.
Logging Rails Loading Times
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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