aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorXu Cheng2015-06-16 15:44:23 +0800
committerXu Cheng2015-06-18 14:46:29 +0800
commit7a59a3ee37966ad2378a3d96fbedde42506c5e00 (patch)
tree53e9c7992fd9492c22a81a80b9d94d2bf7d7c1ec /Library
parent44feb5b8f9bc8b52909d07d6a5ef3d58b343a79f (diff)
downloadbrew-7a59a3ee37966ad2378a3d96fbedde42506c5e00.tar.bz2
audit: add benchmark inject code
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cmd/audit.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/Library/Homebrew/cmd/audit.rb b/Library/Homebrew/cmd/audit.rb
index e3e0166a2..38912aeed 100644
--- a/Library/Homebrew/cmd/audit.rb
+++ b/Library/Homebrew/cmd/audit.rb
@@ -20,6 +20,26 @@ module Homebrew
ENV.activate_extensions!
ENV.setup_build_environment
+ if ARGV.switch? "D"
+ FormulaAuditor.module_eval do
+ instance_methods.grep(/audit_/).map do |name|
+ method = instance_method(name)
+ define_method(name) do |*args, &block|
+ begin
+ time = Time.now
+ method.bind(self).(*args, &block)
+ ensure
+ $times[name] ||= 0
+ $times[name] += Time.now - time
+ end
+ end
+ end
+ end
+
+ $times = {}
+ at_exit { puts $times.sort_by{ |k, v| v }.map{ |k, v| "#{k}: #{v}" } }
+ end
+
ff = if ARGV.named.empty?
Formula
else