Created
February 24, 2009 23:24
-
-
Save nicholasf/69869 to your computer and use it in GitHub Desktop.
ProfilingUtils
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
module ProfilingUtils | |
#only caters for vmmap (os x) and pmap (linux) | |
def ram_footprint | |
footprint = nil | |
case `uname`.strip! | |
when 'Darwin' | |
footprint = `vmmap #{Process.pid} | tail -1`[10,40].strip | |
footprint = footprint.split("[").last | |
footprint = footprint.gsub("]", "") | |
when 'Linux' | |
footprint = `pmap #{Process.pid} | tail -1`[10,40].strip | |
end | |
unless footprint.nil? | |
footprint.gsub!("K", "") | |
end | |
return footprint.to_i | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment