Module: Lrama::Tracer::Duration
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.enable ⇒ Object
15 16 17 |
# File 'lib/lrama/tracer/duration.rb', line 15 def self.enable @_report_duration_enabled = true end |
.enabled? ⇒ 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() time1 = Time.now.to_f result = yield time2 = Time.now.to_f if Duration.enabled? STDERR.puts sprintf("%s %10.5f s", , time2 - time1) end return result end |