Module: LogjamAgent::ComputeRenderTimes

Defined in:
lib/logjam_agent/sinatra.rb

Instance Method Summary collapse

Instance Method Details

#render(engine, data, options = {}, locals = {}, &block) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/logjam_agent/sinatra.rb', line 83

def render(engine, data, options = {}, locals = {}, &block)
  consumed_before_rendering = TimeBandits.consumed
  result = exception = nil
  duration = Benchmark.ms do
    begin
      result = super
    rescue => exception
    end
  end
  consumed_during_rendering = TimeBandits.consumed - consumed_before_rendering
  duration -= consumed_during_rendering
  raise exception if exception
  result
ensure
  Thread.current.thread_variable_set(
    :time_bandits_completed_info,
    [ duration, ["Views: %.3fms" % duration.to_f], duration, "" ]
  )
end