Memory Usage output
This commit is contained in:
@@ -160,3 +160,8 @@ def remove_base64_images_from_html(html)
|
||||
imageregex = %r{data\s*:\s*image/[^\s;]+\s*;\s*base64\s*,\s*}
|
||||
html.gsub(/["']\s*#{imageregex}#{base64regex}\s*["']/, '""')
|
||||
end
|
||||
|
||||
# @return [ Integer ] The memory of the current process in Bytes
|
||||
def get_memory_usage
|
||||
`ps -o rss= -p #{Process.pid}`.to_i * 1024 # ps returns the value in KB
|
||||
end
|
||||
|
||||
@@ -97,3 +97,12 @@ module Terminal
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Numeric
|
||||
def bytes_to_human
|
||||
units = %w{B KB MB GB TB}
|
||||
e = (Math.log(self)/Math.log(1024)).floor
|
||||
s = "%.3f" % (to_f / 1024**e)
|
||||
s.sub(/\.?0*$/, ' ' + units[e])
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user