class Puppet::Util::Profiler::Aggregate
Public Class Methods
new(logger, identifier)
click to toggle source
Calls superclass method
Puppet::Util::Profiler::Logging::new
# File lib/puppet/util/profiler/aggregate.rb 5 def initialize(logger, identifier) 6 super(logger, identifier) 7 @metrics_hash = Metric.new 8 end
Public Instance Methods
do_finish(context, description, metric_id)
click to toggle source
Calls superclass method
Puppet::Util::Profiler::WallClock#do_finish
# File lib/puppet/util/profiler/aggregate.rb 22 def do_finish(context, description, metric_id) 23 result = super(context, description, metric_id) 24 update_metric(@metrics_hash, metric_id, result[:time]) 25 result 26 end
do_start(description, metric_id)
click to toggle source
Calls superclass method
Puppet::Util::Profiler::WallClock#do_start
# File lib/puppet/util/profiler/aggregate.rb 18 def do_start(description, metric_id) 19 super(description, metric_id) 20 end
print_metrics(metrics_hash, prefix)
click to toggle source
# File lib/puppet/util/profiler/aggregate.rb 44 def print_metrics(metrics_hash, prefix) 45 metrics_hash.sort_by {|k,v| v.time }.reverse_each do |k,v| 46 @logger.call("#{prefix}#{k}: #{v.time} s (#{v.count} calls)") 47 print_metrics(metrics_hash[k], "#{prefix}#{k} -> ") 48 end 49 end
shutdown()
click to toggle source
Calls superclass method
Puppet::Util::Profiler::Logging#shutdown
# File lib/puppet/util/profiler/aggregate.rb 10 def shutdown() 11 super 12 @logger.call("AGGREGATE PROFILING RESULTS:") 13 @logger.call("----------------------------") 14 print_metrics(@metrics_hash, "") 15 @logger.call("----------------------------") 16 end
update_metric(metrics_hash, metric_id, time)
click to toggle source
# File lib/puppet/util/profiler/aggregate.rb 28 def update_metric(metrics_hash, metric_id, time) 29 first, *rest = *metric_id 30 if first 31 m = metrics_hash[first] 32 m.increment 33 m.add_time(time) 34 if rest.count > 0 35 update_metric(m, rest, time) 36 end 37 end 38 end
values()
click to toggle source
# File lib/puppet/util/profiler/aggregate.rb 40 def values 41 @metrics_hash 42 end