class RubyProf::MethodInfo

Public Instance Methods

<=>(other) click to toggle source
# File lib/ruby-prof/method_info.rb, line 7
def <=>(other)
  if self.total_time < other.total_time
    -1
  elsif self.total_time > other.total_time
    1
  elsif self.min_depth < other.min_depth
    1
  elsif self.min_depth > other.min_depth
    -1
  else
    self.full_name <=> other.full_name
  end
end
aggregate_children() click to toggle source
# File lib/ruby-prof/method_info.rb, line 93
def aggregate_children
  # group call infos based on their targets
  groups = self.children.each_with_object({}) do |call_info, hash|
    key = call_info.target
    (hash[key] ||= []) << call_info
  end

  groups.map do |key, value|
    AggregateCallInfo.new(value, self)
  end
end
aggregate_parents() click to toggle source
# File lib/ruby-prof/method_info.rb, line 81
def aggregate_parents
  # group call infos based on their parents
  groups = self.call_infos.each_with_object({}) do |call_info, hash|
    key = call_info.parent ? call_info.parent.target : self
    (hash[key] ||= []) << call_info
  end

  groups.map do |key, value|
    AggregateCallInfo.new(value, self)
  end
end
called() click to toggle source
# File lib/ruby-prof/method_info.rb, line 21
def called
  @called ||= begin
    call_infos.inject(0) do |sum, call_info|
      sum + call_info.called
    end
  end
end
children() click to toggle source
# File lib/ruby-prof/method_info.rb, line 73
def children
  @children ||= call_infos.map(&:children).flatten
end
children_time(i = 0) click to toggle source
# File lib/ruby-prof/method_info.rb, line 52
def children_time(i = 0)
  @children_time ||= begin
    call_infos.inject(0) do |sum, call_info|
      sum += call_info.children_time(i) if !call_info.recursive?
      sum
    end
  end
end
min_depth() click to toggle source
# File lib/ruby-prof/method_info.rb, line 61
def min_depth
  @min_depth ||= call_infos.map(&:depth).min
end
parents() click to toggle source
# File lib/ruby-prof/method_info.rb, line 77
def parents
  @parents ||= call_infos.map(&:parent)
end
root?() click to toggle source
# File lib/ruby-prof/method_info.rb, line 65
def root?
  @root ||= begin
    call_infos.find do |call_info|
      not call_info.root?
    end.nil?
  end
end
self_time(i = 0) click to toggle source
# File lib/ruby-prof/method_info.rb, line 38
def self_time(i = 0)
  @self_time ||= []
  @self_time[i] ||= self_time_unmemoized(i)
end
to_s() click to toggle source
# File lib/ruby-prof/method_info.rb, line 105
def to_s
  "#{self.full_name} (c: #{self.called}, tt: #{self.total_time}, st: #{self.self_time}, wt: #{wait_time}, ct: #{self.children_time})"
end
total_time(i = 0) click to toggle source
# File lib/ruby-prof/method_info.rb, line 29
def total_time(i = 0)
  @total_time ||= begin
    call_infos.inject(0) do |sum, call_info|
      sum += call_info.total_time(i) if !call_info.recursive?
      sum
    end
  end
end
wait_time(i = 0) click to toggle source
# File lib/ruby-prof/method_info.rb, line 43
def wait_time(i = 0)
  @wait_time ||= begin
    call_infos.inject(0) do |sum, call_info|
      sum += call_info.wait_time(i) if !call_info.recursive?
      sum
    end
  end
end