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.5.2 lib/facter/framework/benchmarking/timer.rb
facter-4.5.1 lib/facter/framework/benchmarking/timer.rb
facter-4.5.0 lib/facter/framework/benchmarking/timer.rb
facter-4.4.3 lib/facter/framework/benchmarking/timer.rb
facter-4.4.2 lib/facter/framework/benchmarking/timer.rb
facter-4.4.1 lib/facter/framework/benchmarking/timer.rb
facter-4.4.0 lib/facter/framework/benchmarking/timer.rb
facter-4.3.1 lib/facter/framework/benchmarking/timer.rb
facter-4.3.0 lib/facter/framework/benchmarking/timer.rb
facter-4.2.14 lib/facter/framework/benchmarking/timer.rb
facter-4.2.13 lib/facter/framework/benchmarking/timer.rb
facter-4.2.12 lib/facter/framework/benchmarking/timer.rb
facter-4.2.11 lib/facter/framework/benchmarking/timer.rb
facter-4.2.10 lib/facter/framework/benchmarking/timer.rb
facter-4.2.9 lib/facter/framework/benchmarking/timer.rb
facter-4.2.8 lib/facter/framework/benchmarking/timer.rb
facter-4.2.7 lib/facter/framework/benchmarking/timer.rb
facter-4.2.6 lib/facter/framework/benchmarking/timer.rb
facter-4.2.5 lib/facter/framework/benchmarking/timer.rb
facter-4.2.4 lib/facter/framework/benchmarking/timer.rb