From e07f3ddcac394d2a8dc23fc571318b7e8c2497b1 Mon Sep 17 00:00:00 2001 From: claudiob Date: Wed, 17 Dec 2014 12:10:43 -0800 Subject: Add docs for AS::Notifications::Event#duration [ci skip] --- .../lib/active_support/notifications/instrumenter.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/notifications/instrumenter.rb b/activesupport/lib/active_support/notifications/instrumenter.rb index 3a244b34b5..68c553059f 100644 --- a/activesupport/lib/active_support/notifications/instrumenter.rb +++ b/activesupport/lib/active_support/notifications/instrumenter.rb @@ -57,6 +57,18 @@ module ActiveSupport @duration = nil end + # Returns the difference in milliseconds between the moments when the + # execution of the instrumented event started and when it ended. + # + # ActiveSupport::Notifications.subscribe('wait') do |*args| + # @event = ActiveSupport::Notifications::Event.new(*args) + # end + # + # ActiveSupport::Notifications.instrument('wait') do + # sleep 1 + # end + # + # @event.duration #=> 1000.138 def duration @duration ||= 1000.0 * (self.end - time) end -- cgit v1.2.3