Sha256: 8ef2d9a6b9ee7519833f2db5b548fcde65e2fca6c3530ae62ef5d1ad97cd6a4c

Contents?: true

Size: 602 Bytes

Versions: 7

Compression:

Stored size: 602 Bytes

Contents

# frozen_string_literal: true

require 'benchmark'

module Facter
  module Framework
    module Benchmarking
      class Timer
        class << self
          def measure(fact_name, prefix_message = '', &block)
            if Options[:timing]
              time = Benchmark.measure(&block)

              log = "fact '#{fact_name}', took: #{time.format('%r')} seconds"
              prefix_message = "#{prefix_message} " unless prefix_message.empty?
              puts "#{prefix_message}#{log}"
            else
              yield
            end
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
facter-4.10.0 lib/facter/framework/benchmarking/timer.rb
facter-4.9.0 lib/facter/framework/benchmarking/timer.rb
facter-4.8.0 lib/facter/framework/benchmarking/timer.rb
facter-4.7.1 lib/facter/framework/benchmarking/timer.rb
facter-4.7.0 lib/facter/framework/benchmarking/timer.rb
facter-4.6.1 lib/facter/framework/benchmarking/timer.rb
facter-4.6.0 lib/facter/framework/benchmarking/timer.rb