Method: Timer#time

Defined in:
lib/timer.rb

#time(message = "", options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/timer.rb', line 12

def time(message="", options={})
  current_title = options[:title] || title

  start_time = Time.now
  begin
    yield
  rescue StandardError => e
    put_elapsed_time(start_time, Time.now, e.message, current_title)
  end
  put_elapsed_time(start_time, Time.now, message, current_title)
  raise e if e
end