Create a gist now

Instantly share code, notes, and snippets.

Measure how long require(s) take.
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
@dblock
Owner

Add the following to config/boot.rb:

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

Thanks for this! Very useful!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment