class Memory::Aggregate

Constants

Total

Attributes

total[R]

Public Class Methods

new(title, &block) click to toggle source
# File lib/memory/aggregate.rb, line 64
def initialize(title, &block)
        @title = title
        @metric = block
        
        @total = Total.new
        @totals = Hash.new{|h,k| h[k] = Total.new}
end

Public Instance Methods

<<(allocation) click to toggle source
# File lib/memory/aggregate.rb, line 74
def << allocation
        metric = @metric.call(allocation)
        total = @totals[metric]
        
        total.memory += allocation.memsize
        total.count += 1
        
        @total.memory += allocation.memsize
        @total.count += 1
end
print(io = $stderr, limit: 10, title: @title, level: 2) click to toggle source
totals_by(key) click to toggle source
# File lib/memory/aggregate.rb, line 85
def totals_by(key)
        @totals.sort_by{|metric, total| [total[key], metric]}
end