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.27.2 examples/allocations/memory.rb
async-io-1.27.1 examples/allocations/memory.rb
async-io-1.27.0 examples/allocations/memory.rb
async-io-1.26.0 examples/allocations/memory.rb
async-io-1.25.0 examples/allocations/memory.rb
async-io-1.24.0 examples/allocations/memory.rb
async-io-1.23.3 examples/allocations/memory.rb
async-io-1.23.1 examples/allocations/memory.rb
async-io-1.23.0 examples/allocations/memory.rb
async-io-1.22.0 examples/allocations/memory.rb
async-io-1.21.0 examples/allocations/memory.rb
async-io-1.20.0 examples/allocations/memory.rb
async-io-1.18.5 examples/allocations/memory.rb
async-io-1.18.4 examples/allocations/memory.rb
async-io-1.18.3 examples/allocations/memory.rb
async-io-1.18.2 examples/allocations/memory.rb
async-io-1.18.1 examples/allocations/memory.rb
async-io-1.17.2 examples/allocations/memory.rb
async-io-1.17.1 examples/allocations/memory.rb
async-io-1.16.4 examples/allocations/memory.rb