Method: ActiveSupport::Notifications::Event#duration

Defined in:
activesupport/lib/active_support/notifications/instrumenter.rb

#durationObject

Returns the difference in milliseconds between when the execution of the event started and when it ended.

ActiveSupport::Notifications.subscribe('wait') do |event|
  @event = event
end

ActiveSupport::Notifications.instrument('wait') do
  sleep 1
end

@event.duration # => 1000.138


198
199
200
# File 'activesupport/lib/active_support/notifications/instrumenter.rb', line 198

def duration
  @end - @time
end