Class: Flows::Plugin::Profiler::Report::Tree

Inherits:
Flows::Plugin::Profiler::Report show all
Defined in:
lib/flows/plugin/profiler/report/tree.rb,
lib/flows/plugin/profiler/report/tree/node.rb,
lib/flows/plugin/profiler/report/tree/calculated_node.rb

Overview

Tree report. Merges similar calls, saves execution structure (who called whom).

Examples:

Flows::Plugin::Profiler.profile(:tree) do
  # some code here
end

puts Flows::Plugin::Profiler.last_report

Since:

  • 0.4.0

Direct Known Subclasses

Flat

Defined Under Namespace

Classes: CalculatedNode, Node

Instance Attribute Summary

Attributes inherited from Flows::Plugin::Profiler::Report

#raw_data

Instance Method Summary collapse

Methods inherited from Flows::Plugin::Profiler::Report

#events, #initialize

Constructor Details

This class inherits a constructor from Flows::Plugin::Profiler::Report

Instance Method Details

#addObject

Since:

  • 0.4.0



49
50
51
52
# File 'lib/flows/plugin/profiler/report/tree.rb', line 49

def add(*)
  forget_memoized_values
  super
end

#to_aArray<Hash>

Returns tree report as Ruby data structs.

Examples:

[
  {
    subject: 'MyClass#call',
    count: 2,
    total_ms: 100.0,
    total_self_ms: 80.0,
    total_self_percentage: 80.0,
    avg_ms: 50.0,
    avg_self_ms: 40.0,
    nested: [
      {
        subject: 'MyClass#another_method',
        count: 1,
        total_ms: 20.0,
        total_self_ms: 20.0,
        total_self_percentage: 20.0,
        avg_ms: 20.0,
        avg_self_ms: 20.0,
        nested: []
      }
    ]
  }
]

Returns:

  • (Array<Hash>)

    tree report.

Since:

  • 0.4.0



45
46
47
# File 'lib/flows/plugin/profiler/report/tree.rb', line 45

def to_a
  root_calculated_node.children.map { |node| node.to_h(root_calculated_node) }
end

#to_sObject

Since:

  • 0.4.0



54
55
56
# File 'lib/flows/plugin/profiler/report/tree.rb', line 54

def to_s
  root_calculated_node.children.map { |node| node.to_s(root_calculated_node) }.join
end