Sha256: 29d7ed1eac958e81f8eb35e301c1c1cd4264aa00f375142c467fe068d39766df

Contents?: true

Size: 1.48 KB

Versions: 68

Compression:

Stored size: 1.48 KB

Contents

require 'benchmark'

# A simple profiling callback system.
#
# @api public
module Puppet::Util::Profiler
  require 'puppet/util/profiler/wall_clock'
  require 'puppet/util/profiler/object_counts'
  require 'puppet/util/profiler/around_profiler'

  @profiler = Puppet::Util::Profiler::AroundProfiler.new

  # Reset the profiling system to the original state
  #
  # @api private
  def self.clear
    @profiler.clear
  end

  # Retrieve the current list of profilers
  #
  # @api private
  def self.current
    @profiler.current
  end

  # @param profiler [#profile] A profiler for the current thread
  # @api private
  def self.add_profiler(profiler)
    @profiler.add_profiler(profiler)
  end

  # @param profiler [#profile] A profiler to remove from the current thread
  # @api private
  def self.remove_profiler(profiler)
    @profiler.remove_profiler(profiler)
  end

  # 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 hierachy.
  #
  # @param message [String] A description of the profiled event
  # @param metric_id [Array] A list of strings making up the ID of a metric to profile
  # @param block [Block] The segment of code to profile
  # @api public
  def self.profile(message, metric_id, &block)
    @profiler.profile(message, metric_id, &block)
  end
end

Version data entries

68 entries across 68 versions & 2 rubygems

Version Path
puppet-retrospec-1.5.0 vendor/gems/puppet-4.5.2/lib/puppet/util/profiler.rb
puppet-retrospec-1.4.1 vendor/gems/puppet-4.5.2/lib/puppet/util/profiler.rb
puppet-retrospec-1.4.0 vendor/gems/puppet-4.5.2/lib/puppet/util/profiler.rb
puppet-retrospec-1.3.2 vendor/gems/puppet-4.5.2/lib/puppet/util/profiler.rb
puppet-retrospec-1.3.1 vendor/gems/puppet-4.5.2/lib/puppet/util/profiler.rb
puppet-retrospec-1.3.0 vendor/gems/puppet-4.5.2/lib/puppet/util/profiler.rb
puppet-retrospec-1.2.1 vendor/gems/puppet-4.5.2/lib/puppet/util/profiler.rb
puppet-retrospec-1.2.0 vendor/gems/puppet-4.5.2/lib/puppet/util/profiler.rb
puppet-retrospec-1.1.0 vendor/gems/puppet-4.5.2/lib/puppet/util/profiler.rb
puppet-4.5.3 lib/puppet/util/profiler.rb
puppet-4.5.3-x86-mingw32 lib/puppet/util/profiler.rb
puppet-4.5.3-x64-mingw32 lib/puppet/util/profiler.rb
puppet-4.5.3-universal-darwin lib/puppet/util/profiler.rb
puppet-retrospec-1.0.0 vendor/gems/puppet-4.5.2/lib/puppet/util/profiler.rb
puppet-4.5.2 lib/puppet/util/profiler.rb
puppet-4.5.2-x86-mingw32 lib/puppet/util/profiler.rb
puppet-4.5.2-x64-mingw32 lib/puppet/util/profiler.rb
puppet-4.5.2-universal-darwin lib/puppet/util/profiler.rb
puppet-4.5.1 lib/puppet/util/profiler.rb
puppet-4.5.1-x86-mingw32 lib/puppet/util/profiler.rb