lib/console/measure.rb in console-1.11.0 vs lib/console/measure.rb in console-1.11.1

- old
+ new

@@ -21,26 +21,29 @@ require_relative 'event/measure' require_relative 'clock' module Console class Measure - def initialize(output, subject) + def initialize(output, subject, **tags) @output = output @subject = subject + @tags = tags end + attr :tags + # Measure the execution of a block of code. - def duration(name, **tags, &block) + def duration(name, &block) @output.info(@subject) {Event::Enter.new(name)} start_time = Clock.now - yield + result = yield(self) duration = Clock.now - start_time - @output.info(@subject) {Event::Exit.new(name, duration, **tags)} + @output.info(@subject) {Event::Exit.new(name, duration, **@tags)} - return duration + return result end end end