Sha256: aa1580f44ef9356ef2cdf34d786c7976b9b865b6ff619a2a87bc56ebb84cfc5a

Contents?: true

Size: 1.04 KB

Versions: 18

Compression:

Stored size: 1.04 KB

Contents

module RubyProf
  class AggregateCallInfo
    attr_reader :call_infos
    def initialize(call_infos)
      if call_infos.length == 0
        raise(ArgumentError, "Must specify at least one call info.")
      end
      @call_infos = call_infos
    end

    def target
      call_infos.first.target
    end

    def parent
      call_infos.first.parent
    end

    def line
      call_infos.first.line
    end

    def children
      call_infos.inject(Array.new) do |result, call_info|
        result.concat(call_info.children)
      end
    end

    def total_time
      aggregate(:total_time)
    end

    def self_time
      aggregate(:self_time)
    end

    def wait_time
      aggregate(:wait_time)
    end

    def children_time
      aggregate(:children_time)
    end

    def called
      aggregate(:called)
    end

    def to_s
      "#{call_infos.first.full_name}"
    end

    private

    def aggregate(method_name)
      self.call_infos.inject(0) do |sum, call_info|
        sum += call_info.send(method_name)
        sum
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 4 rubygems

Version Path
adamh-ruby-prof-0.7.3 lib/ruby-prof/aggregate_call_info.rb
ruby-prof-danielhoey-0.8.1 lib/ruby-prof/aggregate_call_info.rb
ruby-prof-0.8.2 lib/ruby-prof/aggregate_call_info.rb
ruby-prof-0.8.1-x86-mingw32 lib/ruby-prof/aggregate_call_info.rb
ruby-prof-0.8.1-x86-mswin32 lib/ruby-prof/aggregate_call_info.rb
ruby-prof-0.8.1 lib/ruby-prof/aggregate_call_info.rb
ruby-prof-0.7.10 lib/ruby-prof/aggregate_call_info.rb
ruby-prof-0.7.9 lib/ruby-prof/aggregate_call_info.rb
ruby-prof-0.7.8 lib/ruby-prof/aggregate_call_info.rb
ruby-prof-0.7.7 lib/ruby-prof/aggregate_call_info.rb
ruby-prof-0.7.6 lib/ruby-prof/aggregate_call_info.rb
ruby-prof-0.7.5 lib/ruby-prof/aggregate_call_info.rb
ruby-prof-0.7.4 lib/ruby-prof/aggregate_call_info.rb
rdp-ruby-prof-0.7.4 lib/ruby-prof/aggregate_call_info.rb
ruby-prof-0.7.2 lib/ruby-prof/aggregate_call_info.rb
ruby-prof-0.7.3-x86-mswin32-60 lib/ruby-prof/aggregate_call_info.rb
ruby-prof-0.7.2-x86-mswin32-60 lib/ruby-prof/aggregate_call_info.rb
ruby-prof-0.7.3 lib/ruby-prof/aggregate_call_info.rb