Skip to content

Commit

Permalink
Autolink references for AS::Notifications::Instrumenter [ci-skip]
Browse files Browse the repository at this point in the history
This also rewords occurrences of "made since the call to `start!` and
the call to `finish!`" to "made between the call to `start!` and the
call to `finish!`", for clarity.
  • Loading branch information
jonathanhefner committed Oct 7, 2023
1 parent 0f535a8 commit e5124ae
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions activesupport/lib/active_support/notifications/instrumenter.rb
Expand Up @@ -65,16 +65,16 @@ def instrument(name, payload = {})
end
end

# Returns a "handle" for an event with the given +name+ and +payload+
# Returns a "handle" for an event with the given +name+ and +payload+.
#
# +#start+ and +#finish+ must each be called exactly once on the returned object.
# #start and #finish must each be called exactly once on the returned object.
#
# Where possible, it's best to use +#instrument+, which will record the
# Where possible, it's best to use #instrument, which will record the
# start and finish of the event and correctly handle any exceptions.
# +build_handle+ is a low-level API intended for cases where using
# +#instrument+ isn't possible.
# +instrument+ isn't possible.
#
# See ActiveSupport::Notifications::Fanout::Handle
# See ActiveSupport::Notifications::Fanout::Handle.
def build_handle(name, payload)
@notifier.build_handle(name, @id, payload)
end
Expand Down Expand Up @@ -146,21 +146,21 @@ def finish!
@allocation_count_finish = now_allocations
end

# Returns the CPU time (in milliseconds) passed since the call to
# +start!+ and the call to +finish!+
# Returns the CPU time (in milliseconds) passed between the call to
# #start! and the call to #finish!.
def cpu_time
@cpu_time_finish - @cpu_time_start
end

# Returns the idle time time (in milliseconds) passed since the call to
# +start!+ and the call to +finish!+
# Returns the idle time time (in milliseconds) passed between the call to
# #start! and the call to #finish!.
def idle_time
diff = duration - cpu_time
diff > 0.0 ? diff : 0.0
end

# Returns the number of allocations made since the call to +start!+ and
# the call to +finish!+
# Returns the number of allocations made between the call to #start! and
# the call to #finish!.
def allocations
@allocation_count_finish - @allocation_count_start
end
Expand Down

0 comments on commit e5124ae

Please sign in to comment.