Module: Lrama::Tracer::Duration

Included in:
Context, Output, Reporter, States
Defined in:
lib/lrama/tracer/duration.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.enableObject



15
16
17
# File 'lib/lrama/tracer/duration.rb', line 15

def self.enable
  @_report_duration_enabled = true
end

.enabled?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/lrama/tracer/duration.rb', line 20

def self.enabled?
  !!@_report_duration_enabled
end

Instance Method Details

#report_duration(message) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/lrama/tracer/duration.rb', line 25

def report_duration(message)
  time1 = Time.now.to_f
  result = yield
  time2 = Time.now.to_f

  if Duration.enabled?
    STDERR.puts sprintf("%s %10.5f s", message, time2 - time1)
  end

  return result
end