class RequireProf::RequireTree

Attributes

memory[RW]
name[R]
overhead_time[RW]
time[RW]
total_memory[RW]
total_time[RW]

Public Class Methods

new(name) click to toggle source
# File lib/require_prof/require_tree.rb, line 7
def initialize(name)
  @name = name
  @children = {}
  @time = 0.0
  @total_time = 0.0
  @overhead_time = 0.0
  @memory = 0.0
  @total_memory = 0.0
end

Public Instance Methods

<<(tree) click to toggle source
# File lib/require_prof/require_tree.rb, line 17
def <<(tree)
  @children[tree.name] ||= tree
end
[](name) click to toggle source
# File lib/require_prof/require_tree.rb, line 21
def [](name)
  @children[name]
end
children() click to toggle source
# File lib/require_prof/require_tree.rb, line 25
def children
  @children.values
end
process_memory() click to toggle source
# File lib/require_prof/require_tree.rb, line 36
def process_memory
  children.map(&:process_memory)
  @memory = total_memory - children.map(&:total_memory).reduce(:+).to_f
end
process_time() click to toggle source
# File lib/require_prof/require_tree.rb, line 29
def process_time
  children.map(&:process_time)
  @overhead_time += children.map(&:overhead_time ).reduce(:+).to_f
  @total_time -= overhead_time
  @time = total_time - children.map(&:total_time).reduce(:+).to_f
end
to_h() click to toggle source
# File lib/require_prof/require_tree.rb, line 41
def to_h
  {
    name: name,
    children: children.map(&:to_h),
    time: time,
    total_time: total_time,
    memory: memory,
    total_memory: total_memory
  }
end