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
-
#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 WallClock
Methods inherited from Logging
Constructor Details
Instance Method Details
#do_finish(context, description, metric_id) ⇒ Object
20 21 22 23 24 |
# File 'lib/puppet/util/profiler/aggregate.rb', line 20 def do_finish(context, description, metric_id) result = super(context, description, metric_id) update_metric(@metrics_hash, metric_id, result[:time]) result end |
#print_metrics(metrics_hash, prefix) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/puppet/util/profiler/aggregate.rb', line 42 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
12 13 14 15 16 17 18 |
# File 'lib/puppet/util/profiler/aggregate.rb', line 12 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
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/puppet/util/profiler/aggregate.rb', line 26 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
38 39 40 |
# File 'lib/puppet/util/profiler/aggregate.rb', line 38 def values @metrics_hash end |