Class: Test::Unit::Util::MemoryUsage
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/test/unit/util/memory-usage.rb |
Class Method Summary
- .new ⇒ MemoryUsage constructor
Instance Attribute Summary
- #collected? ⇒ Boolean readonly
- #physical readonly
- #virtual readonly
Instance Method Summary
- #collect_data private
- #collect_data_proc private
Constructor Details
.new ⇒ MemoryUsage
# File 'lib/test/unit/util/memory-usage.rb', line 7
def initialize @virtual = nil @physical = nil collect_data end
Instance Attribute Details
#collected? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/test/unit/util/memory-usage.rb', line 13
def collected? return false if @virtual.nil? return false if @physical.nil? true end
#physical (readonly)
[ GitHub ]# File 'lib/test/unit/util/memory-usage.rb', line 6
attr_reader :physical
#virtual (readonly)
[ GitHub ]# File 'lib/test/unit/util/memory-usage.rb', line 5
attr_reader :virtual
Instance Method Details
#collect_data (private)
[ GitHub ]# File 'lib/test/unit/util/memory-usage.rb', line 20
def collect_data collect_data_proc end
#collect_data_proc (private)
[ GitHub ]# File 'lib/test/unit/util/memory-usage.rb', line 24
def collect_data_proc status_file = "/proc/self/status" return false unless File.exist?(status_file) data = File.binread(status_file) data.each_line do |line| case line when /\AVm(Size|RSS):\s*(\d+)\s*kB/ name = $1 value = Integer($2, 10) * 1024 case name when "Size" @virtual = value when "RSS" @physical = value end end end collected? end