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