class Hotch::Memory::Report::Line

rubocop:disable Style/StructInheritance

Constants

MAX_PATH_LENGTH

Public Class Methods

from_result(result, ignore_paths) click to toggle source

[

[path, lineno, type],
[count, old_count, total_age, min_age, max_age, total_memsize]

]

# File lib/hotch/memory.rb, line 154
def self.from_result(result, ignore_paths)
  path, line, *args = result.flatten(1)
  return if ignore_paths.any? { |ip| ip == path || ip === path }

  filename = "#{strip_path(path)}:#{line}"
  new(filename, *args)
end
strip_path(path) click to toggle source
# File lib/hotch/memory.rb, line 182
def self.strip_path(path)
  return "?" unless path

  strip = %r{#{Regexp.union($LOAD_PATH)}/?}
  path.gsub!(strip, "")
  if path.size > MAX_PATH_LENGTH + 3
    # TODO: Refactor
    "...#{path[-MAX_PATH_LENGTH..]}"
  else
    path
  end
end

Public Instance Methods

key() click to toggle source
# File lib/hotch/memory.rb, line 162
def key
  [filename, type]
end
lengths() click to toggle source
# File lib/hotch/memory.rb, line 171
def lengths
  members.map { |member| self[member].to_s.size }
end
puts(io, fmt) click to toggle source
# File lib/hotch/memory.rb, line 166
def puts(io, fmt)
  send = method(:send)
  io.puts fmt % members.map(&send)
end
sum(other) click to toggle source
# File lib/hotch/memory.rb, line 175
def sum(other)
  other.to_a.each.with_index do |value, i|
    self[i] += value if Numeric === value
  end
end