Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added Rubinius::Analyst#itemized_memory.

  • Loading branch information...
commit f130fde44310442bdfd3590b1406d8bfec37b3d0 1 parent 050b38f
Brian Shirai brixen authored
Showing with 16 additions and 1 deletion.
  1. +16 −1 lib/rubinius/analyst.rb
17 lib/rubinius/analyst.rb
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.