Module: Munch
- Defined in:
- lib/munch.rb,
lib/munch/version.rb
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
Class Method Details
.get(txt = nil, before = nil) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/munch.rb', line 14 def self.get(txt = nil, before = nil) GetProcessMem.new.mb.round.tap do |mb| txt += " - " if txt msg = "#{txt}Memory usage : #{mb} MB" msg += " (#{format("%+d", mb - before)} MB)" if before puts msg end end |
.track(tag = nil) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/munch.rb', line 5 def self.track(tag = nil) tag = "[#{tag.upcase}] " if tag key = rand(36**8).to_s(36) mb = get("#{tag}Before #{key}") yield get("#{tag}After #{key}", mb) end |