Class: Puppet::Util::Profiler::Aggregate
- Defined in:
- lib/puppet/util/profiler/aggregate.rb
Defined Under Namespace
Instance Method Summary collapse
- #do_finish(context, description, metric_id) ⇒ Object
- #do_start(description, metric_id) ⇒ Object
-
#initialize(logger, identifier) ⇒ Aggregate
constructor
A new instance of Aggregate.
- #print_metrics(metrics_hash, prefix) ⇒ Object
- #shutdown ⇒ Object
- #update_metric(metrics_hash, metric_id, time) ⇒ Object
- #values ⇒ Object
Methods inherited from Logging
Constructor Details
Instance Method Details
#do_finish(context, description, metric_id) ⇒ Object
23 24 25 26 27 |
# File 'lib/puppet/util/profiler/aggregate.rb', line 23 def do_finish(context, description, metric_id) result = super(context, description, metric_id) update_metric(@metrics_hash, metric_id, result[:time]) result end |
#do_start(description, metric_id) ⇒ Object
19 20 21 |
# File 'lib/puppet/util/profiler/aggregate.rb', line 19 def do_start(description, metric_id) super(description, metric_id) end |
#print_metrics(metrics_hash, prefix) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/puppet/util/profiler/aggregate.rb', line 45 def print_metrics(metrics_hash, prefix) metrics_hash.sort_by {|k,v| v.time }.reverse_each do |k,v| @logger.call("#{prefix}#{k}: #{v.time} s (#{v.count} calls)") print_metrics(metrics_hash[k], "#{prefix}#{k} -> ") end end |
#shutdown ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/puppet/util/profiler/aggregate.rb', line 11 def shutdown() super @logger.call("AGGREGATE PROFILING RESULTS:") @logger.call("----------------------------") print_metrics(@metrics_hash, "") @logger.call("----------------------------") end |
#update_metric(metrics_hash, metric_id, time) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/puppet/util/profiler/aggregate.rb', line 29 def update_metric(metrics_hash, metric_id, time) first, *rest = *metric_id if first m = metrics_hash[first] m.increment m.add_time(time) if rest.count > 0 update_metric(m, rest, time) end end end |
#values ⇒ Object
41 42 43 |
# File 'lib/puppet/util/profiler/aggregate.rb', line 41 def values @metrics_hash end |