Skip to content

Commit

Permalink
Added Rubinius::Analyst#itemized_memory.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Ford committed Apr 26, 2011
1 parent 050b38f commit f130fde
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lib/rubinius/analyst.rb
Expand Up @@ -19,12 +19,27 @@ def initialize
@agent = Rubinius::Agent.loopback
end

MEMORY_BANKS = [:young, :mature, :large, :code, :symbols]

def total_memory
total = [:young, :mature, :large, :code, :symbols].inject(0) do |s, m|
total = MEMORY_BANKS.inject(0) do |s, m|
s + @agent.get("system.memory.#{m}.bytes").last
end

auto_bytes total
end

def itemized_memory
total = 0
output = ""
MEMORY_BANKS.each do |m|
size = @agent.get("system.memory.#{m}.bytes").last
output += "#{m.to_s.capitalize.rjust(7)}: #{auto_bytes size}\n"
total += size
end
output += "\n Total: #{auto_bytes total}\n"

output
end
end
end

0 comments on commit f130fde

Please sign in to comment.