Created
July 3, 2009 08:57
-
-
Save alexyoung/140012 to your computer and use it in GitHub Desktop.
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
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 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks, added memory used from gist#264496, http://gist.github.com/465431