Class: Flows::Plugin::Profiler::Report::Tree::CalculatedNode Private
- Inherits:
-
Object
- Object
- Flows::Plugin::Profiler::Report::Tree::CalculatedNode
- Defined in:
- lib/flows/plugin/profiler/report/tree/calculated_node.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- MICROSECONDS_IN_MILLISECOND =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
1000.0
Instance Attribute Summary collapse
- #children ⇒ Object readonly private
Instance Method Summary collapse
- #avg_ms ⇒ Object private
- #avg_self_ms ⇒ Object private
- #children_ms ⇒ Object private
- #count ⇒ Object private
-
#group_by_subject ⇒ Object
private
:reek:DuplicateMethodCall :reek:NestedIterators.
-
#initialize(node) ⇒ CalculatedNode
constructor
private
A new instance of CalculatedNode.
- #subject ⇒ Object private
-
#to_h(root_node = self) ⇒ Object
private
rubocop:disable Metrics/MethodLength.
- #to_s(root_node = self) ⇒ Object private
- #total_ms ⇒ Object private
- #total_percentage(root_node = self) ⇒ Object private
- #total_self_ms ⇒ Object private
- #total_self_percentage(root_node = self) ⇒ Object private
Constructor Details
#initialize(node) ⇒ CalculatedNode
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of CalculatedNode.
12 13 14 15 16 17 18 |
# File 'lib/flows/plugin/profiler/report/tree/calculated_node.rb', line 12 def initialize(node) @node = node @children = node.children .map { |child| self.class.new(child) } .sort_by(&:total_ms) .reverse end |
Instance Attribute Details
#children ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
10 11 12 |
# File 'lib/flows/plugin/profiler/report/tree/calculated_node.rb', line 10 def children @children end |
Instance Method Details
#avg_ms ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
32 33 34 |
# File 'lib/flows/plugin/profiler/report/tree/calculated_node.rb', line 32 def avg_ms @avg_ms ||= total_ms / count end |
#avg_self_ms ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
52 53 54 |
# File 'lib/flows/plugin/profiler/report/tree/calculated_node.rb', line 52 def avg_self_ms @avg_self_ms ||= total_self_ms / count end |
#children_ms ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
36 37 38 |
# File 'lib/flows/plugin/profiler/report/tree/calculated_node.rb', line 36 def children_ms @children_ms ||= children.map(&:total_ms).sort.sum end |
#count ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
24 25 26 |
# File 'lib/flows/plugin/profiler/report/tree/calculated_node.rb', line 24 def count @count ||= @node.executions.count end |
#group_by_subject ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
:reek:DuplicateMethodCall :reek:NestedIterators
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/flows/plugin/profiler/report/tree/calculated_node.rb', line 76 def group_by_subject @group_by_subject ||= ( [children.group_by(&:subject)] + children.map(&:group_by_subject) ).each_with_object({}) do |group, result| group.each do |subject, nodes| result[subject] ||= [] result[subject] += nodes end end end |
#subject ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 |
# File 'lib/flows/plugin/profiler/report/tree/calculated_node.rb', line 20 def subject @node.subject end |
#to_h(root_node = self) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
rubocop:disable Metrics/MethodLength
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/flows/plugin/profiler/report/tree/calculated_node.rb', line 56 def to_h(root_node = self) # rubocop:disable Metrics/MethodLength @to_h ||= { subject: subject, count: count, total_ms: total_ms, total_percentage: total_percentage(root_node), total_self_ms: total_self_ms, total_self_percentage: total_self_percentage(root_node), avg_ms: avg_ms, avg_self_ms: avg_self_ms, nested: children.map { |node| node.to_h(root_node) } } end |
#to_s(root_node = self) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
70 71 72 |
# File 'lib/flows/plugin/profiler/report/tree/calculated_node.rb', line 70 def to_s(root_node = self) @to_s ||= (base_text_list(root_node) + childeren_text_list(root_node)).join("\n") end |
#total_ms ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
28 29 30 |
# File 'lib/flows/plugin/profiler/report/tree/calculated_node.rb', line 28 def total_ms @total_ms ||= @node.executions.sort.sum / MICROSECONDS_IN_MILLISECOND end |
#total_percentage(root_node = self) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
48 49 50 |
# File 'lib/flows/plugin/profiler/report/tree/calculated_node.rb', line 48 def total_percentage(root_node = self) @total_percentage ||= total_ms / root_node.children_ms * 100.0 end |
#total_self_ms ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
40 41 42 |
# File 'lib/flows/plugin/profiler/report/tree/calculated_node.rb', line 40 def total_self_ms @total_self_ms ||= total_ms - children_ms end |
#total_self_percentage(root_node = self) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
44 45 46 |
# File 'lib/flows/plugin/profiler/report/tree/calculated_node.rb', line 44 def total_self_percentage(root_node = self) @total_self_percentage ||= total_self_ms / root_node.children_ms * 100.0 end |