Sha256: 8a53848066cf539390277247d9dd1283677ee07209c62f4b9b509449065a680c

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

require_relative 'flat/method_report'

module Flows
  module Plugin
    module Profiler
      class Report
        # Flat report. Merges similar calls, hides execution structure.
        #
        # It's a variation of a {Rport::Tree} where all calls of the same method
        # are combined into a one first-level entry.
        #
        # @example
        #     Flows::Plugin::Profiler.profile(:flat) do
        #       # some code here
        #     end
        #
        #     puts Flows::Plugin::Profiler.last_report
        class Flat < Tree
          def to_a
            method_reports.map(&:to_h)
          end

          def to_s
            method_reports.map(&:to_s).join("\n")
          end

          private

          def method_reports
            @method_reports ||= root_calculated_node
                                .group_by_subject
                                .values
                                .map { |nodes| MethodReport.new(root_calculated_node, *nodes) }
                                .sort_by(&:total_self_ms)
                                .reverse
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
flows-0.6.0 lib/flows/plugin/profiler/report/flat.rb
flows-0.5.1 lib/flows/plugin/profiler/report/flat.rb
flows-0.5.0 lib/flows/plugin/profiler/report/flat.rb