audit: add benchmark inject code
This commit is contained in:
parent
44feb5b8f9
commit
7a59a3ee37
@ -20,6 +20,26 @@ module Homebrew
|
|||||||
ENV.activate_extensions!
|
ENV.activate_extensions!
|
||||||
ENV.setup_build_environment
|
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?
|
ff = if ARGV.named.empty?
|
||||||
Formula
|
Formula
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user