Method: Puppet::Util::Profiler::AroundProfiler#profile
- Defined in:
- lib/puppet/util/profiler/around_profiler.rb
#profile(message, metric_id) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Profile a block of code and log the time it took to execute.
This outputs logs entries to the Puppet masters logging destination providing the time it took, a message describing the profiled code and a leaf location marking where the profile method was called in the profiled hierarchy.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/puppet/util/profiler/around_profiler.rb', line 51 def profile(, metric_id) retval = nil contexts = {} @profilers.each do |profiler| contexts[profiler] = profiler.start(, metric_id) end begin retval = yield ensure @profilers.each do |profiler| profiler.finish(contexts[profiler], , metric_id) end end retval end |