Class: TraceViz::TraceData::SummaryNode

Inherits:
Node
  • Object
show all
Defined in:
lib/trace_viz/trace_data/summary_node.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#children, #parent

Attributes included from TraceViz::Traits::TimeTrackable

#timestamp

Attributes included from TraceViz::Traits::DepthTrackable

#depth

Instance Method Summary collapse

Methods inherited from Node

#add_child, #add_children, #to_h

Methods inherited from Base

#line_number, #to_h

Methods included from TraceViz::Traits::TimeTrackable

#record_timestamp

Methods included from TraceViz::Traits::DepthTrackable

#assign_depth

Methods included from Helpers::ConfigHelper

#config, #fetch_general_config

Constructor Details

#initialize(group:) ⇒ SummaryNode

Returns a new instance of SummaryNode.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/trace_viz/trace_data/summary_node.rb', line 10

def initialize(group:)
  super()

  @group = group
  @count = group.size

  @representative_node = group.first
  @depth = representative_node.depth
  @event = representative_node.event
  @klass = representative_node.klass
  @path = representative_node.path
  @action = representative_node.action

  # Representative node is the first node in the group belonging to MethodCall
  @params = representative_node.params
  @result = representative_node.method_return.result

  add_children(representative_node.children)
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



8
9
10
# File 'lib/trace_viz/trace_data/summary_node.rb', line 8

def action
  @action
end

#countObject (readonly)

Returns the value of attribute count.



8
9
10
# File 'lib/trace_viz/trace_data/summary_node.rb', line 8

def count
  @count
end

#eventObject (readonly)

Returns the value of attribute event.



8
9
10
# File 'lib/trace_viz/trace_data/summary_node.rb', line 8

def event
  @event
end

#groupObject (readonly)

Returns the value of attribute group.



8
9
10
# File 'lib/trace_viz/trace_data/summary_node.rb', line 8

def group
  @group
end

#klassObject (readonly)

Returns the value of attribute klass.



8
9
10
# File 'lib/trace_viz/trace_data/summary_node.rb', line 8

def klass
  @klass
end

#paramsObject (readonly)

Returns the value of attribute params.



8
9
10
# File 'lib/trace_viz/trace_data/summary_node.rb', line 8

def params
  @params
end

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/trace_viz/trace_data/summary_node.rb', line 8

def path
  @path
end

#representative_nodeObject (readonly)

Returns the value of attribute representative_node.



8
9
10
# File 'lib/trace_viz/trace_data/summary_node.rb', line 8

def representative_node
  @representative_node
end

#resultObject (readonly)

Returns the value of attribute result.



8
9
10
# File 'lib/trace_viz/trace_data/summary_node.rb', line 8

def result
  @result
end

Instance Method Details

#durationObject



34
35
36
37
38
# File 'lib/trace_viz/trace_data/summary_node.rb', line 34

def duration
  return 0 if count.zero?

  total_duration / count
end

#keyObject



30
31
32
# File 'lib/trace_viz/trace_data/summary_node.rb', line 30

def key
  :summary_group
end

#total_durationObject



40
41
42
# File 'lib/trace_viz/trace_data/summary_node.rb', line 40

def total_duration
  children.map(&:duration).sum
end