Created
February 18, 2013 22:10
-
-
Save dblock/4981231 to your computer and use it in GitHub Desktop.
Measure how long require(s) take.
This file contains 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
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am not using Rails....how would I enable this same solution? I don't use a framework since it's not a web-app, it's interacting with API's.