Class: Flows::Plugin::Profiler::Report::Flat::MethodReport Private
- Inherits:
-
Object
- Object
- Flows::Plugin::Profiler::Report::Flat::MethodReport
- Defined in:
- lib/flows/plugin/profiler/report/flat/method_report.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.
Instance Attribute Summary collapse
- #calculated_nodes ⇒ Object readonly private
- #root_node ⇒ Object readonly private
Instance Method Summary collapse
- #avg_self_ms ⇒ Object private
- #count ⇒ Object private
- #direct_subcalls ⇒ Object private
-
#initialize(root_node, *calculated_nodes) ⇒ MethodReport
constructor
private
A new instance of MethodReport.
- #subject ⇒ Object private
- #to_h ⇒ Object private
- #to_s ⇒ Object private
- #total_self_ms ⇒ Object private
- #total_self_percentage ⇒ Object private
Constructor Details
#initialize(root_node, *calculated_nodes) ⇒ MethodReport
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 MethodReport.
11 12 13 14 15 16 17 |
# File 'lib/flows/plugin/profiler/report/flat/method_report.rb', line 11 def initialize(root_node, *calculated_nodes) @root_node = root_node @calculated_nodes = calculated_nodes raise 'no single node provided' if calculated_nodes.empty? raise 'calculated_nodes must be about the same subject' unless nodes_have_same_subject end |
Instance Attribute Details
#calculated_nodes ⇒ 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.
9 10 11 |
# File 'lib/flows/plugin/profiler/report/flat/method_report.rb', line 9 def calculated_nodes @calculated_nodes end |
#root_node ⇒ 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.
8 9 10 |
# File 'lib/flows/plugin/profiler/report/flat/method_report.rb', line 8 def root_node @root_node end |
Instance Method Details
#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.
38 39 40 |
# File 'lib/flows/plugin/profiler/report/flat/method_report.rb', line 38 def avg_self_ms @avg_self_ms ||= total_self_ms / count 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.
23 24 25 |
# File 'lib/flows/plugin/profiler/report/flat/method_report.rb', line 23 def count @count ||= calculated_nodes.map(&:count).sum end |
#direct_subcalls ⇒ 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.
42 43 44 45 46 |
# File 'lib/flows/plugin/profiler/report/flat/method_report.rb', line 42 def direct_subcalls @direct_subcalls ||= calculated_nodes .flat_map { |node| node.children.map(&:subject) } .uniq 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.
19 20 21 |
# File 'lib/flows/plugin/profiler/report/flat/method_report.rb', line 19 def subject @subject ||= calculated_nodes.first.subject end |
#to_h ⇒ 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 51 52 53 54 55 56 57 |
# File 'lib/flows/plugin/profiler/report/flat/method_report.rb', line 48 def to_h @to_h ||= { subject: subject, count: count, total_self_ms: total_self_ms, total_self_percentage: total_self_percentage, avg_self_ms: avg_self_ms, direct_subcalls: direct_subcalls } end |
#to_s ⇒ 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.
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/flows/plugin/profiler/report/flat/method_report.rb', line 59 def to_s [ '', "- #{subject} -", "called: #{count} time(s)", "total self execution time: #{total_self_ms.truncate(2)}ms", "total self percentage: #{total_self_percentage.truncate(2)}%", "average self execution time: #{avg_self_ms.truncate(2)}ms", "direct subcalls: #{direct_subcalls.join(', ')}" ] 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.
27 28 29 |
# File 'lib/flows/plugin/profiler/report/flat/method_report.rb', line 27 def total_self_ms @total_self_ms ||= calculated_nodes.map(&:total_self_ms).sort.sum end |
#total_self_percentage ⇒ 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.
31 32 33 34 35 36 |
# File 'lib/flows/plugin/profiler/report/flat/method_report.rb', line 31 def total_self_percentage @total_self_percentage ||= calculated_nodes .map { |node| node.total_self_percentage(root_node) } .sort .sum end |