Module: Puppet::Util::Profiler

Defined in:
lib/puppet/util/profiler.rb

Overview

A simple profiling callback system.

Defined Under Namespace

Classes: Aggregate, AroundProfiler, Logging, ObjectCounts, WallClock

Class Method Summary collapse

Class Method Details

.add_profiler(profiler) ⇒ 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.

Parameters:

  • profiler (#profile)

    A profiler for the current thread



30
31
32
# File 'lib/puppet/util/profiler.rb', line 30

def self.add_profiler(profiler)
  @profiler.add_profiler(profiler)
end

.clearObject

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.

Reset the profiling system to the original state



17
18
19
# File 'lib/puppet/util/profiler.rb', line 17

def self.clear
  @profiler.clear
end

.currentObject

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.

Retrieve the current list of profilers



24
25
26
# File 'lib/puppet/util/profiler.rb', line 24

def self.current
  @profiler.current
end

.profile(message, metric_id, &block) ⇒ Object

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.

Parameters:

  • message (String)

    A description of the profiled event

  • metric_id (Array)

    A list of strings making up the ID of a metric to profile

  • block (Block)

    The segment of code to profile



51
52
53
# File 'lib/puppet/util/profiler.rb', line 51

def self.profile(message, metric_id, &block)
  @profiler.profile(message, metric_id, &block)
end

.remove_profiler(profiler) ⇒ 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.

Parameters:

  • profiler (#profile)

    A profiler to remove from the current thread



36
37
38
# File 'lib/puppet/util/profiler.rb', line 36

def self.remove_profiler(profiler)
  @profiler.remove_profiler(profiler)
end