class RubyProf::AggregateCallInfo

Attributes

call_infos[R]
method_info[R]

Public Class Methods

new(call_infos, method_info) click to toggle source
# File lib/ruby-prof/aggregate_call_info.rb, line 7
def initialize(call_infos, method_info)
  if call_infos.length == 0
    raise(ArgumentError, "Must specify at least one call info.")
  end
  @call_infos = call_infos
  @method_info = method_info
end

Public Instance Methods

called() click to toggle source
# File lib/ruby-prof/aggregate_call_info.rb, line 49
def called
  aggregate_all(:called)
end
children() click to toggle source
# File lib/ruby-prof/aggregate_call_info.rb, line 27
def children
  call_infos.inject(Array.new) do |result, call_info|
    result.concat(call_info.children)
  end
end
children_time(i = 0) click to toggle source
# File lib/ruby-prof/aggregate_call_info.rb, line 45
def children_time(i = 0)
  aggregate_roots(:children_time, i)
end
line() click to toggle source
# File lib/ruby-prof/aggregate_call_info.rb, line 23
def line
  call_infos.first.line
end
parent() click to toggle source
# File lib/ruby-prof/aggregate_call_info.rb, line 19
def parent
  call_infos.first.parent
end
self_time(i = 0) click to toggle source
# File lib/ruby-prof/aggregate_call_info.rb, line 37
def self_time(i = 0)
  aggregate_roots(:self_time, i)
end
target() click to toggle source
# File lib/ruby-prof/aggregate_call_info.rb, line 15
def target
  call_infos.first.target
end
to_s() click to toggle source
# File lib/ruby-prof/aggregate_call_info.rb, line 53
def to_s
  "#{call_infos.first.target.full_name}"
end
total_time(i = 0) click to toggle source
# File lib/ruby-prof/aggregate_call_info.rb, line 33
def total_time(i = 0)
  aggregate_roots(:total_time, i)
end
wait_time(i = 0) click to toggle source
# File lib/ruby-prof/aggregate_call_info.rb, line 41
def wait_time(i = 0)
  aggregate_roots(:wait_time, i)
end

Private Instance Methods

aggregate_all(method_name) click to toggle source
# File lib/ruby-prof/aggregate_call_info.rb, line 64
def aggregate_all(method_name)
  call_infos.inject(0) do |sum, call_info|
    sum + call_info.send(method_name)
  end
end
aggregate_roots(method_name, *args) click to toggle source
# File lib/ruby-prof/aggregate_call_info.rb, line 70
def aggregate_roots(method_name, *args)
  roots.inject(0) do |sum, call_info|
    sum + call_info.send(method_name, *args)
  end
end
roots() click to toggle source

return all call_infos which are not (grand) children of any other node in the list of given call_infos

# File lib/ruby-prof/aggregate_call_info.rb, line 60
def roots
  @roots ||= method_info.recursive? ? CallInfo.roots_of(call_infos) : call_infos
end