Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Measure how long require(s) take.

View debug_require.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
if ENV['DEBUG_REQUIRE']
require 'benchmark'
 
def require(file)
@@first ||= Time.now
rc = false
ts = Benchmark.measure do
rc = super
end
if ENV['DEBUG_REQUIRE'].to_f < ts.total
total = ts.format("%t require #{file}")
from_start = (Time.now - @@first).to_i
$stdout.puts "#{total} (#{from_start} second(s) from start)"
end
rc
end
end
Owner

Add the following to config/boot.rb:

require File.expand_path('../initializers/debug_require', __FILE__)

Thanks for this! Very useful!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.