class Flows::Plugin::Profiler::Report::Flat::MethodReport
@api private
Attributes
calculated_nodes[R]
root_node[R]
Public Class Methods
new(root_node, *calculated_nodes)
click to toggle source
# 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
Public Instance Methods
avg_self_ms()
click to toggle source
# 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()
click to toggle source
# File lib/flows/plugin/profiler/report/flat/method_report.rb, line 22 def count @count ||= calculated_nodes.map(&:count).sum end
direct_subcalls()
click to toggle source
# 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()
click to toggle source
# File lib/flows/plugin/profiler/report/flat/method_report.rb, line 18 def subject @subject ||= calculated_nodes.first.subject end
to_h()
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# 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
Private Instance Methods
nodes_have_same_subject()
click to toggle source
# File lib/flows/plugin/profiler/report/flat/method_report.rb, line 72 def nodes_have_same_subject calculated_nodes.all? { |node| node.subject == subject } end