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
22 23 24 25 26 |
# File 'lib/puppet/util/profiler/aggregate.rb', line 22 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
18 19 20 |
# File 'lib/puppet/util/profiler/aggregate.rb', line 18 def do_start(description, metric_id) super(description, metric_id) end |
#print_metrics(metrics_hash, prefix) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/puppet/util/profiler/aggregate.rb', line 44 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
10 11 12 13 14 15 16 |
# File 'lib/puppet/util/profiler/aggregate.rb', line 10 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
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/puppet/util/profiler/aggregate.rb', line 28 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
40 41 42 |
# File 'lib/puppet/util/profiler/aggregate.rb', line 40 def values @metrics_hash end |