Sha256: 1ad2abcf43826bd35104580f7e64556ac5b7580bc2d2fd30bf57bf6636bd80f1

Contents?: true

Size: 767 Bytes

Versions: 395

Compression:

Stored size: 767 Bytes

Contents

require 'puppet/util/profiler/logging'

# A profiler implementation that measures the number of seconds a segment of
# code takes to execute and provides a callback with a string representation of
# the profiling information.
#
# @api private
class Puppet::Util::Profiler::WallClock < Puppet::Util::Profiler::Logging
  def do_start(description, metric_id)
    Timer.new
  end

  def do_finish(context, description, metric_id)
    {:time => context.stop,
     :msg => _("took %{context} seconds") % { context: context }}
  end

  class Timer
    FOUR_DECIMAL_DIGITS = '%0.4f'

    def initialize
      @start = Time.now
    end

    def stop
      @time = Time.now - @start
      @time
    end

    def to_s
      format(FOUR_DECIMAL_DIGITS, @time)
    end
  end
end

Version data entries

395 entries across 395 versions & 2 rubygems

Version Path
puppet-5.5.22 lib/puppet/util/profiler/wall_clock.rb
puppet-5.5.22-x86-mingw32 lib/puppet/util/profiler/wall_clock.rb
puppet-5.5.22-x64-mingw32 lib/puppet/util/profiler/wall_clock.rb
puppet-5.5.22-universal-darwin lib/puppet/util/profiler/wall_clock.rb
puppet-6.19.0 lib/puppet/util/profiler/wall_clock.rb
puppet-6.19.0-x86-mingw32 lib/puppet/util/profiler/wall_clock.rb
puppet-6.19.0-x64-mingw32 lib/puppet/util/profiler/wall_clock.rb
puppet-6.19.0-universal-darwin lib/puppet/util/profiler/wall_clock.rb
puppet-6.18.0 lib/puppet/util/profiler/wall_clock.rb
puppet-6.18.0-x86-mingw32 lib/puppet/util/profiler/wall_clock.rb
puppet-6.18.0-x64-mingw32 lib/puppet/util/profiler/wall_clock.rb
puppet-6.18.0-universal-darwin lib/puppet/util/profiler/wall_clock.rb
puppet-6.17.0 lib/puppet/util/profiler/wall_clock.rb
puppet-6.17.0-x86-mingw32 lib/puppet/util/profiler/wall_clock.rb
puppet-6.17.0-x64-mingw32 lib/puppet/util/profiler/wall_clock.rb
puppet-6.17.0-universal-darwin lib/puppet/util/profiler/wall_clock.rb
puppet-5.5.21 lib/puppet/util/profiler/wall_clock.rb
puppet-5.5.21-x86-mingw32 lib/puppet/util/profiler/wall_clock.rb
puppet-5.5.21-x64-mingw32 lib/puppet/util/profiler/wall_clock.rb
puppet-5.5.21-universal-darwin lib/puppet/util/profiler/wall_clock.rb