Created
February 18, 2011 21:56
-
-
Save brixen/834491 to your computer and use it in GitHub Desktop.
Easy tool for checking how much memory Rubinius uses
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rbx memory.rb | |
memory used: 19.4M | |
$ bin/mspec ci -T -rmemory core/array | |
rubinius 1.2.1 (1.8.7 cdbdd275 2011-02-15 JI) [i686-apple-darwin9.8.0] | |
................................................................................................................ | |
Finished in 3.992361 seconds | |
112 files, 2166 examples, 4420 expectations, 0 failures, 0 errors | |
memory used: 22.7M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubinius/agent' | |
class MemoryCheck | |
include Rubinius::Stats::Units | |
def initialize | |
@agent = Rubinius::Agent.loopback | |
end | |
def check | |
total = [:young, :mature, :large, :code, :symbols].inject(0) do |s, m| | |
s + @agent.get("system.memory.#{m}.bytes").last | |
end | |
auto_bytes total | |
end | |
end | |
at_exit do | |
puts "memory used: #{MemoryCheck.new.check}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment