Sha256: 0abccb023e42a103b31d2fd1b089e0a339f0c03db0124b71cda54cb01e969408

Contents?: true

Size: 1.16 KB

Versions: 18

Compression:

Stored size: 1.16 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/none'

  NONE = Puppet::Util::Profiler::None.new

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

  # @return This thread's configured profiler
  # @api private
  def self.current
    @profiler || NONE
  end

  # @param profiler [#profile] A profiler for the current thread
  # @api private
  def self.current=(profiler)
    @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 block [Block] The segment of code to profile
  # @api public
  def self.profile(message, &block)
    current.profile(message, &block)
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
puppet-3.6.2 lib/puppet/util/profiler.rb
puppet-3.6.2-x86-mingw32 lib/puppet/util/profiler.rb
puppet-3.6.1 lib/puppet/util/profiler.rb
puppet-3.6.1-x86-mingw32 lib/puppet/util/profiler.rb
puppet-3.6.0 lib/puppet/util/profiler.rb
puppet-3.6.0-x86-mingw32 lib/puppet/util/profiler.rb
puppet-3.6.0.rc1 lib/puppet/util/profiler.rb
puppet-3.6.0.rc1-x86-mingw32 lib/puppet/util/profiler.rb
puppet-3.5.1 lib/puppet/util/profiler.rb
puppet-3.5.1-x86-mingw32 lib/puppet/util/profiler.rb
puppet-3.5.1.rc1 lib/puppet/util/profiler.rb
puppet-3.5.1.rc1-x86-mingw32 lib/puppet/util/profiler.rb
puppet-3.5.0.rc3 lib/puppet/util/profiler.rb
puppet-3.5.0.rc3-x86-mingw32 lib/puppet/util/profiler.rb
puppet-3.5.0.rc2 lib/puppet/util/profiler.rb
puppet-3.5.0.rc2-x86-mingw32 lib/puppet/util/profiler.rb
puppet-3.5.0.rc1 lib/puppet/util/profiler.rb
puppet-3.5.0.rc1-x86-mingw32 lib/puppet/util/profiler.rb