Skip to content

Instantly share code, notes, and snippets.

@alexyoung
Created July 3, 2009 08:57
Show Gist options
  • Save alexyoung/140012 to your computer and use it in GitHub Desktop.
Save alexyoung/140012 to your computer and use it in GitHub Desktop.
require 'benchmark'
module Kernel
alias old_require require
def require(path)
#unless caller.find { |caller_line| caller_line.match /dependencies\.rb/ }
# return old_require(path)
#end
output = nil
@required_files ||= []
benchmark = Benchmark.measure do
output = old_require path
end
@required_files << [path, benchmark]
puts path
caller.each do |caller_line|
puts "\t#{caller_line}"
end
puts ""
#puts "#{path}:"
#puts loading_benchmark
output
end
def print_require_benchmark_stats
puts "Printing benchmark stats:"
@required_files ||= []
@required_files.sort! { |a, b| b[1].real <=> a[1].real }
@required_files.each do |path, benchmark|
puts path
puts benchmark
end
end
end
at_exit { print_require_benchmark_stats }
@deepak
Copy link

deepak commented Jul 6, 2010

thanks, added memory used from gist#264496, http://gist.github.com/465431

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