Class: Facter::Framework::Benchmarking::Timer

Inherits:
Object
  • Object
show all
Defined in:
lib/facter/framework/benchmarking/timer.rb

Class Method Summary collapse

Class Method Details

.measure(fact_name, prefix_message = '', &block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/facter/framework/benchmarking/timer.rb', line 10

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