instance method
exclusive_duration_sum
Ruby on Rails edge
Since edge Private — implementation detail, not part of the public APISignature
exclusive_duration_sum(events)
Sum durations for one event name without double-counting nested events. Nested notifications (e.g. a partial that renders another partial) report inclusive durations; subtracting direct same-name children yields exclusive time so the metric stays within wall-clock bounds.
Parameters
-
eventsreq
Source
# File actionpack/lib/action_dispatch/middleware/server_timing.rb, line 83
def exclusive_duration_sum(events)
return 0.0 if events.empty?
return events.first.duration if events.one?
sorted = events.sort_by { |event| [event.time, -event.duration] }
children_ms = Hash.new(0.0)
stack = []
sorted.each do |event|
while stack.any? && stack.last.end <= event.time
stack.pop
end
if stack.any? && event.end <= stack.last.end
children_ms[stack.last] += event.duration
end
stack << event
end
events.sum { |event| event.duration - children_ms[event] }
end
Defined in actionpack/lib/action_dispatch/middleware/server_timing.rb line 83
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionDispatch::ServerTiming