Module: BuildpackSupport::Component::WithTiming

Included in:
Downloads
Defined in:
lib/buildpack_support/component/with_timing.rb

Overview

A mixin for printing out a caption and timing when executing a block

Instance Method Summary collapse

Instance Method Details

#with_timing(caption) ⇒ Void

Wrap the execution of a block with timing information

Parameters:

  • caption (String)

    the caption to print when timing starts

Returns:

  • (Void)


28
29
30
31
32
33
34
35
# File 'lib/buildpack_support/component/with_timing.rb', line 28

def with_timing(caption)
  start_time = Time.now
  print "       #{caption} "

  yield

  puts "(#{(Time.now - start_time).duration})"
end