Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Rubinius::Analyst#itemized_memory.
Browse files Browse the repository at this point in the history
Brian Ford committed Apr 26, 2011

Verified

This commit was signed with the committer’s verified signature.
headius Charles Oliver Nutter
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
Original file line number Diff line number Diff line change
@@ -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.