Class: DebugTimer::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/debug_timer/node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Node

Returns a new instance of Node.



4
5
6
7
8
9
10
11
# File 'lib/debug_timer/node.rb', line 4

def initialize(name)
  @name = name
  @children = []
  if DebugTimer.object_allocations?
    grab_object_allocations(true)
  end
  @start_time = Time.now
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



3
4
5
# File 'lib/debug_timer/node.rb', line 3

def children
  @children
end

#end_gc_statsObject (readonly)

Returns the value of attribute end_gc_stats.



3
4
5
# File 'lib/debug_timer/node.rb', line 3

def end_gc_stats
  @end_gc_stats
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/debug_timer/node.rb', line 3

def name
  @name
end

#parentObject (readonly)

Returns the value of attribute parent.



3
4
5
# File 'lib/debug_timer/node.rb', line 3

def parent
  @parent
end

#start_gc_statsObject (readonly)

Returns the value of attribute start_gc_stats.



3
4
5
# File 'lib/debug_timer/node.rb', line 3

def start_gc_stats
  @start_gc_stats
end

#start_timeObject (readonly)

Returns the value of attribute start_time.



3
4
5
# File 'lib/debug_timer/node.rb', line 3

def start_time
  @start_time
end

#time_elapsedObject (readonly)

Returns the value of attribute time_elapsed.



3
4
5
# File 'lib/debug_timer/node.rb', line 3

def time_elapsed
  @time_elapsed
end

Instance Method Details



20
21
22
# File 'lib/debug_timer/node.rb', line 20

def print(depth:)
  NodePrinter.new(self).print(depth)
end

#stopObject



13
14
15
16
17
18
# File 'lib/debug_timer/node.rb', line 13

def stop
  @time_elapsed = Time.now - start_time
  if DebugTimer.object_allocations?
    grab_object_allocations(false)
  end
end