Module: Lrama::Report::Duration
- Defined in:
- lib/lrama/report/duration.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.enable ⇒ Object
4 5 6 |
# File 'lib/lrama/report/duration.rb', line 4 def self.enable @_report_duration_enabled = true end |
.enabled? ⇒ Boolean
8 9 10 |
# File 'lib/lrama/report/duration.rb', line 8 def self.enabled? !!@_report_duration_enabled end |
Instance Method Details
#report_duration(method_name) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/lrama/report/duration.rb', line 12 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 |