aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/notifications
diff options
context:
space:
mode:
authorclaudiob <claudiob@gmail.com>2014-12-17 12:10:43 -0800
committerclaudiob <claudiob@gmail.com>2014-12-17 12:10:43 -0800
commite07f3ddcac394d2a8dc23fc571318b7e8c2497b1 (patch)
tree982382841aa94406171764d79c517d9da4a8f003 /activesupport/lib/active_support/notifications
parent2ed2be1ccc0893b7b16ed16004b20bb992a06526 (diff)
downloadrails-e07f3ddcac394d2a8dc23fc571318b7e8c2497b1.tar.gz
rails-e07f3ddcac394d2a8dc23fc571318b7e8c2497b1.tar.bz2
rails-e07f3ddcac394d2a8dc23fc571318b7e8c2497b1.zip
Add docs for AS::Notifications::Event#duration
[ci skip]
Diffstat (limited to 'activesupport/lib/active_support/notifications')
-rw-r--r--activesupport/lib/active_support/notifications/instrumenter.rb12
1 files changed, 12 insertions, 0 deletions
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