aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMax Howell2012-08-14 11:21:33 -0400
committerMax Howell2012-08-14 11:46:18 -0400
commitfef6d5b8c08bfe94538f34c83e51200df69377d6 (patch)
tree219d0c9837e95d1c1564d743d96b130694baaa81 /Library
parent9fffbde987286990c66ad118c91c2de5ac90f29d (diff)
downloadbrew-fef6d5b8c08bfe94538f34c83e51200df69377d6.tar.bz2
`brew doctor -D` (diagnostic-dump)
-D is now the switch for diagnostic-dumps. Let it be so. Shows how long each doctor method takes in a sorted table at end. I used this to move the two slowest methods to the end of the doctor run so that as much useful information can be shown as quickly as possible. Also now possible to specify on command line which tests should be run.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cmd/doctor.rb29
1 files changed, 27 insertions, 2 deletions
diff --git a/Library/Homebrew/cmd/doctor.rb b/Library/Homebrew/cmd/doctor.rb
index 41f952b1e..6f7d29343 100644
--- a/Library/Homebrew/cmd/doctor.rb
+++ b/Library/Homebrew/cmd/doctor.rb
@@ -706,7 +706,7 @@ def __check_linked_brew f
return links_found
end
-def check_for_linked_kegonly_brews
+def check_for_linked_keg_only_brews
require 'formula'
warnings = Hash.new
@@ -933,7 +933,16 @@ module Homebrew extend self
def doctor
checks = Checks.new
- checks.methods.select{ |method| method =~ /^check_/ }.sort.each do |method|
+ inject_dump_stats(checks) if ARGV.switch? 'D'
+
+ methods = if ARGV.named.empty?
+ # put slowest methods last
+ checks.methods.sort << "check_for_linked_keg_only_brews" << "check_for_outdated_homebrew"
+ else
+ ARGV.named
+ end.select{ |method| method =~ /^check_/ }.uniq
+
+ methods.each do |method|
out = checks.send(method)
unless out.nil? or out.empty?
lines = out.to_s.split('\n')
@@ -945,4 +954,20 @@ module Homebrew extend self
puts "Your system is raring to brew." unless Homebrew.failed?
end
+
+ def inject_dump_stats checks
+ class << checks
+ alias_method :oldsend, :send
+ def send method
+ time = Time.now
+ oldsend(method)
+ ensure
+ $times[method] = Time.now - time
+ end
+ end
+ $times = {}
+ at_exit {
+ puts $times.sort_by{|k, v| v }.map{|k, v| "#{k}: #{v}"}
+ }
+ end
end