Sha256: 90fe17a975586ae42095f59cbd143a67a54046aab00336e71d931b66058ef13a

Contents?: true

Size: 596 Bytes

Versions: 34

Compression:

Stored size: 596 Bytes

Contents

# frozen_string_literal: true

require 'benchmark'

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

              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

34 entries across 34 versions & 1 rubygems

Version Path
facter-4.2.3 lib/facter/framework/benchmarking/timer.rb
facter-4.2.2 lib/facter/framework/benchmarking/timer.rb
facter-4.2.1 lib/facter/framework/benchmarking/timer.rb
facter-4.2.0 lib/facter/framework/benchmarking/timer.rb
facter-4.1.1 lib/facter/framework/benchmarking/timer.rb
facter-4.1.0 lib/facter/framework/benchmarking/timer.rb
facter-4.0.52 lib/facter/framework/benchmarking/timer.rb
facter-4.0.51 lib/facter/framework/benchmarking/timer.rb
facter-4.0.50 lib/facter/framework/benchmarking/timer.rb
facter-4.0.49 lib/facter/framework/benchmarking/timer.rb
facter-4.0.48 lib/facter/framework/benchmarking/timer.rb
facter-4.0.47 lib/facter/framework/benchmarking/timer.rb
facter-4.0.46 lib/facter/framework/benchmarking/timer.rb
facter-4.0.44 lib/facter/framework/benchmarking/timer.rb