Class: Flows::Plugin::Profiler::Report
- Inherits:
-
Object
- Object
- Flows::Plugin::Profiler::Report
- Defined in:
- lib/flows/plugin/profiler/report.rb,
lib/flows/plugin/profiler/report/raw.rb,
lib/flows/plugin/profiler/report/flat.rb,
lib/flows/plugin/profiler/report/tree.rb,
lib/flows/plugin/profiler/report/events.rb,
lib/flows/plugin/profiler/report/tree/node.rb,
lib/flows/plugin/profiler/report/flat/method_report.rb,
lib/flows/plugin/profiler/report/tree/calculated_node.rb
Overview
Base class for Flows::Plugin::Profiler reports.
Defined Under Namespace
Classes: Event, FinishEvent, Flat, Raw, StartEvent, Tree
Instance Attribute Summary collapse
-
#raw_data ⇒ Array<Array>
readonly
Raw profiler events.
Instance Method Summary collapse
-
#add(*args) ⇒ Object
Add event to profile report.
-
#events ⇒ Array<Event>
Array of events.
-
#initialize ⇒ Report
constructor
A new instance of Report.
-
#to_s ⇒ String
abstract
Human-readable representation.
Constructor Details
#initialize ⇒ Report
Returns a new instance of Report.
18 19 20 |
# File 'lib/flows/plugin/profiler/report.rb', line 18 def initialize @raw_data = [] end |
Instance Attribute Details
#raw_data ⇒ Array<Array> (readonly)
Returns raw profiler events.
16 17 18 |
# File 'lib/flows/plugin/profiler/report.rb', line 16 def raw_data @raw_data end |
Instance Method Details
#add(*args) ⇒ Object
Add event to profile report.
30 31 32 |
# File 'lib/flows/plugin/profiler/report.rb', line 30 def add(*args) raw_data << args end |
#events ⇒ Array<Event>
Returns array of events.
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/flows/plugin/profiler/report.rb', line 35 def events raw_data.map do |raw_event| klass = case raw_event.first when :started then StartEvent when :finished then FinishEvent end klass.new(*raw_event[1..-1]) end end |
#to_s ⇒ String
This method is abstract.
Returns human-readable representation.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/flows/plugin/profiler/report.rb', line 14 class Report # @return [Array<Array>] raw profiler events attr_reader :raw_data def initialize @raw_data = [] end # Add event to profile report. # # @param event_type [:started, :finished] event type # @param klass [Class] class where called method is placed # @param method_type [:instance, :singleton] method type # @param method_name [Symbol] name of the called method # @param data [nil, Float] event data, time represented as # a Float microseconds value. def add(*args) raw_data << args end # @return [Array<Event>] array of events def events raw_data.map do |raw_event| klass = case raw_event.first when :started then StartEvent when :finished then FinishEvent end klass.new(*raw_event[1..-1]) end end end |