Sha256: 5fdac7673b63f36ee5199d0dcbc555e6d9d0314364e14b986c9ba99f4c789081

Contents?: true

Size: 810 Bytes

Versions: 40

Compression:

Stored size: 810 Bytes

Contents

class Puppet::Util::Profiler::Logging
  def initialize(logger, identifier)
    @logger = logger
    @identifier = identifier
    @sequence = Sequence.new
  end

  def profile(description, &block)
    retval = nil
    @sequence.next
    @sequence.down
    context = start
    begin
      retval = yield
    ensure
      profile_explanation = finish(context)
      @sequence.up
      @logger.call("PROFILE [#{@identifier}] #{@sequence} #{description}: #{profile_explanation}")
    end
    retval
  end

  class Sequence
    INITIAL = 0
    SEPARATOR = '.'

    def initialize
      @elements = [INITIAL]
    end

    def next
      @elements[-1] += 1
    end

    def down
      @elements << INITIAL
    end

    def up
      @elements.pop
    end

    def to_s
      @elements.join(SEPARATOR)
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

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