Sha256: 6d7c5768e903b30b03f5ea55b62a883537cb0a67cc1f152a34115d937d1ef71c

Contents?: true

Size: 352 Bytes

Versions: 32

Compression:

Stored size: 352 Bytes

Contents

def measure_memory(annotation = "Memory allocated")
	GC.disable
	
	start_memory = `ps -p #{Process::pid} -o rss`.split("\n")[1].chomp.to_i

	yield
	
ensure
	end_memory = `ps -p #{Process::pid} -o rss`.split("\n")[1].chomp.to_i
	memory_usage = (end_memory - start_memory).to_f / 1024
	
	puts "#{memory_usage.round(1)} MB: #{annotation}"
	GC.enable
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
async-io-1.16.3 examples/allocations/memory.rb
async-io-1.16.2 examples/allocations/memory.rb
async-io-1.16.1 examples/allocations/memory.rb
async-io-1.16.0 examples/allocations/memory.rb
async-io-1.15.5 examples/allocations/memory.rb
async-io-1.15.4 examples/allocations/memory.rb
async-io-1.15.3 examples/allocations/memory.rb
async-io-1.15.2 examples/allocations/memory.rb
async-io-1.15.1 examples/allocations/memory.rb
async-io-1.15.0 examples/allocations/memory.rb
async-io-1.14.0 examples/allocations/memory.rb
async-io-1.13.0 examples/allocations/memory.rb