Sha256: a6c767045f549f01b22691ff4c34d90ca4b68b7be9c82d918f7aa8f6176b004d
Contents?: true
Size: 1.33 KB
Versions: 12
Compression:
Stored size: 1.33 KB
Contents
# encoding: utf-8 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_without_recursion(:total_time) end def self_time aggregate_without_recursion(:self_time) end def wait_time aggregate_without_recursion(:wait_time) end def children_time aggregate_without_recursion(:children_time) end def called aggregate(:called) end def to_s "#{call_infos.first.target.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 def aggregate_without_recursion(method_name) self.call_infos.inject(0) do |sum, call_info| sum += call_info.send(method_name) unless call_info.recursive sum end end end end
Version data entries
12 entries across 12 versions & 1 rubygems