Sha256: fe4b65bbc94c713fbe3ba9d414b0cce2185a964736fc81be8993c2d213d5eea7

Contents?: true

Size: 811 Bytes

Versions: 57

Compression:

Stored size: 811 Bytes

Contents

require 'monitor'

Puppet::Util::Instrumentation.new_listener(:performance) do

  attr_reader :samples

  def initialize
    @samples = {}.extend(MonitorMixin)
  end

  def notify(label, event, data)
    return if event == :start

    duration = data[:finished] - data[:started]
    samples.synchronize do
      @samples[label] ||= { :count => 0, :max => 0, :min => nil, :sum => 0, :average => 0 }
      @samples[label][:count] += 1
      @samples[label][:sum] += duration
      @samples[label][:max] = [ @samples[label][:max], duration ].max
      @samples[label][:min] = [ @samples[label][:min], duration ].reject { |val| val.nil? }.min
      @samples[label][:average] = @samples[label][:sum] / @samples[label][:count]
    end
  end

  def data
    samples.synchronize do
      @samples.dup
    end
  end
end

Version data entries

57 entries across 57 versions & 3 rubygems

Version Path
puppet-parse-0.0.2 lib/vendor/puppet/util/instrumentation/listeners/performance.rb
puppet-2.7.20 lib/puppet/util/instrumentation/listeners/performance.rb
puppet-2.7.20.rc1 lib/puppet/util/instrumentation/listeners/performance.rb
puppet-3.0.1 lib/puppet/util/instrumentation/listeners/performance.rb
puppet-3.0.1.rc1 lib/puppet/util/instrumentation/listeners/performance.rb
puppet-3.0.0 lib/puppet/util/instrumentation/listeners/performance.rb
puppet-3.0.0.rc8 lib/puppet/util/instrumentation/listeners/performance.rb
puppet-3.0.0.rc7 lib/puppet/util/instrumentation/listeners/performance.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/puppet-2.7.18/lib/puppet/util/instrumentation/listeners/performance.rb
puppet-3.0.0.rc5 lib/puppet/util/instrumentation/listeners/performance.rb
puppet-3.0.0.rc4 lib/puppet/util/instrumentation/listeners/performance.rb
puppet-2.7.19 lib/puppet/util/instrumentation/listeners/performance.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/puppet-2.7.18/lib/puppet/util/instrumentation/listeners/performance.rb
puppet-2.7.18 lib/puppet/util/instrumentation/listeners/performance.rb
puppet-2.7.17 lib/puppet/util/instrumentation/listeners/performance.rb
puppet-2.7.16 lib/puppet/util/instrumentation/listeners/performance.rb
puppet-2.7.14 lib/puppet/util/instrumentation/listeners/performance.rb