class Console::Measure
Attributes
Public Class Methods
new(output, subject, **tags)
click to toggle source
# File lib/console/measure.rb, line 26 def initialize(output, subject, **tags) @output = output @subject = subject @tags = tags end
Public Instance Methods
duration(name) { |self| ... }
click to toggle source
Measure
the execution of a block of code.
# File lib/console/measure.rb, line 35 def duration(name, &block) @output.info(@subject) {Event::Enter.new(name)} start_time = Clock.now result = yield(self) duration = Clock.now - start_time @output.info(@subject) {Event::Exit.new(name, duration, **@tags)} return result end