Module: Lrama::Report::Duration

Included in:
Context, Output, States, StatesReporter
Defined in:
lib/lrama/report/duration.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.enableObject



6
7
8
# File 'lib/lrama/report/duration.rb', line 6

def self.enable
  @_report_duration_enabled = true
end

.enabled?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/lrama/report/duration.rb', line 10

def self.enabled?
  !!@_report_duration_enabled
end

Instance Method Details

#report_duration(method_name) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/lrama/report/duration.rb', line 14

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

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

  return result
end