Class: WasTracer::Node
- Inherits:
-
Object
- Object
- WasTracer::Node
- Defined in:
- lib/was_tracer/node.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#entry_line ⇒ Object
Returns the value of attribute entry_line.
-
#exit_line ⇒ Object
Returns the value of attribute exit_line.
-
#level ⇒ Object
Returns the value of attribute level.
-
#more_data ⇒ Object
Returns the value of attribute more_data.
-
#parent ⇒ Object
Returns the value of attribute parent.
Instance Method Summary collapse
- #children_duration ⇒ Object
- #details ⇒ Object
- #duration ⇒ Object
- #duration_str ⇒ Object
- #each_long_children ⇒ Object
- #first_child ⇒ Object
- #has_children? ⇒ Boolean
- #has_details? ⇒ Boolean
- #has_long_children? ⇒ Boolean
-
#initialize(level) ⇒ Node
constructor
A new instance of Node.
- #last_child ⇒ Object
- #lines_str ⇒ Object
- #longer_child_duration ⇒ Object
- #more_details ⇒ Object
- #self_duration ⇒ Object
- #self_duration_str ⇒ Object
- #time ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(level) ⇒ Node
Returns a new instance of Node.
7 8 9 10 11 |
# File 'lib/was_tracer/node.rb', line 7 def initialize(level) @children = [] @level = level @more_data = [] end |
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
5 6 7 |
# File 'lib/was_tracer/node.rb', line 5 def children @children end |
#entry_line ⇒ Object
Returns the value of attribute entry_line.
5 6 7 |
# File 'lib/was_tracer/node.rb', line 5 def entry_line @entry_line end |
#exit_line ⇒ Object
Returns the value of attribute exit_line.
5 6 7 |
# File 'lib/was_tracer/node.rb', line 5 def exit_line @exit_line end |
#level ⇒ Object
Returns the value of attribute level.
5 6 7 |
# File 'lib/was_tracer/node.rb', line 5 def level @level end |
#more_data ⇒ Object
Returns the value of attribute more_data.
5 6 7 |
# File 'lib/was_tracer/node.rb', line 5 def more_data @more_data end |
#parent ⇒ Object
Returns the value of attribute parent.
5 6 7 |
# File 'lib/was_tracer/node.rb', line 5 def parent @parent end |
Instance Method Details
#children_duration ⇒ Object
51 52 53 |
# File 'lib/was_tracer/node.rb', line 51 def children_duration @children.inject(0) { |s, child| s += child.duration } end |
#details ⇒ Object
71 72 73 74 75 |
# File 'lib/was_tracer/node.rb', line 71 def details det = lines_str det << " PARAMS: {#{entry_line.method_params}} - RETURN: {#{exit_line.method_params}}" if has_details? det end |
#duration ⇒ Object
34 35 36 |
# File 'lib/was_tracer/node.rb', line 34 def duration @duration ||= exit_line.time - entry_line.time end |
#duration_str ⇒ Object
43 44 45 |
# File 'lib/was_tracer/node.rb', line 43 def duration_str '%07.3f' % duration end |
#each_long_children ⇒ Object
30 31 32 |
# File 'lib/was_tracer/node.rb', line 30 def each_long_children @children.each { |c| yield(c) if c.duration > 0 } end |
#first_child ⇒ Object
13 14 15 |
# File 'lib/was_tracer/node.rb', line 13 def first_child @children.first end |
#has_children? ⇒ Boolean
25 26 27 |
# File 'lib/was_tracer/node.rb', line 25 def has_children? @children.size > 0 end |
#has_details? ⇒ Boolean
59 60 61 |
# File 'lib/was_tracer/node.rb', line 59 def has_details? entry_line != exit_line end |
#has_long_children? ⇒ Boolean
21 22 23 |
# File 'lib/was_tracer/node.rb', line 21 def has_long_children? @children.any? { |c| c.duration > 0 } end |
#last_child ⇒ Object
17 18 19 |
# File 'lib/was_tracer/node.rb', line 17 def last_child @children.last end |
#lines_str ⇒ Object
67 68 69 |
# File 'lib/was_tracer/node.rb', line 67 def lines_str has_details? ? "LINES: #{entry_line.line_number} - #{exit_line.line_number}" : "LINE: #{entry_line.line_number}" end |
#longer_child_duration ⇒ Object
82 83 84 85 |
# File 'lib/was_tracer/node.rb', line 82 def longer_child_duration return 0 if @children.size == 0 @children.max { |c1, c2| c1.duration <=> c2.duration }.duration end |
#more_details ⇒ Object
77 78 79 80 |
# File 'lib/was_tracer/node.rb', line 77 def more_details return "" if more_data.size == 0 "<pre>" << more_data.inject("") { |total, data| total << CGI.escapeHTML(data) } << "</pre>" end |
#self_duration ⇒ Object
38 39 40 |
# File 'lib/was_tracer/node.rb', line 38 def self_duration @self_duration ||= (duration - children_duration).abs end |
#self_duration_str ⇒ Object
47 48 49 |
# File 'lib/was_tracer/node.rb', line 47 def self_duration_str '%07.3f' % self_duration end |
#time ⇒ Object
63 64 65 |
# File 'lib/was_tracer/node.rb', line 63 def time has_details? ? "#{entry_line.time_str} - #{exit_line.time_str}" : entry_line.time_str end |
#to_s ⇒ Object
55 56 57 |
# File 'lib/was_tracer/node.rb', line 55 def to_s entry_line.method_name end |