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.
10 11 12 13 14 15 16 |
# File 'lib/flows/plugin/profiler/report/flat/method_report.rb', line 10 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.
8 9 10 |
# File 'lib/flows/plugin/profiler/report/flat/method_report.rb', line 8 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.
37 38 39 |
# File 'lib/flows/plugin/profiler/report/flat/method_report.rb', line 37 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.
22 23 24 |
# File 'lib/flows/plugin/profiler/report/flat/method_report.rb', line 22 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.
41 42 43 44 45 |
# File 'lib/flows/plugin/profiler/report/flat/method_report.rb', line 41 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.
18 19 20 |
# File 'lib/flows/plugin/profiler/report/flat/method_report.rb', line 18 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.
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/flows/plugin/profiler/report/flat/method_report.rb', line 47 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.
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/flows/plugin/profiler/report/flat/method_report.rb', line 58 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.
26 27 28 |
# File 'lib/flows/plugin/profiler/report/flat/method_report.rb', line 26 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.
30 31 32 33 34 35 |
# File 'lib/flows/plugin/profiler/report/flat/method_report.rb', line 30 def total_self_percentage @total_self_percentage ||= calculated_nodes .map { |node| node.total_self_percentage(root_node) } .sort .sum end |