Class: Pitchfork::MemInfo
- Inherits:
-
Object
- Object
- Pitchfork::MemInfo
- Defined in:
- lib/pitchfork/mem_info.rb
Instance Attribute Summary collapse
-
#pss ⇒ Object
readonly
Returns the value of attribute pss.
-
#rss ⇒ Object
readonly
Returns the value of attribute rss.
-
#shared_memory ⇒ Object
readonly
Returns the value of attribute shared_memory.
Instance Method Summary collapse
- #cow_efficiency(parent_meminfo) ⇒ Object
-
#initialize(pid) ⇒ MemInfo
constructor
A new instance of MemInfo.
- #update ⇒ Object
Constructor Details
#initialize(pid) ⇒ MemInfo
Returns a new instance of MemInfo.
7 8 9 10 |
# File 'lib/pitchfork/mem_info.rb', line 7 def initialize(pid) @pid = pid update end |
Instance Attribute Details
#pss ⇒ Object (readonly)
Returns the value of attribute pss.
5 6 7 |
# File 'lib/pitchfork/mem_info.rb', line 5 def pss @pss end |
#rss ⇒ Object (readonly)
Returns the value of attribute rss.
5 6 7 |
# File 'lib/pitchfork/mem_info.rb', line 5 def rss @rss end |
#shared_memory ⇒ Object (readonly)
Returns the value of attribute shared_memory.
5 6 7 |
# File 'lib/pitchfork/mem_info.rb', line 5 def shared_memory @shared_memory end |
Instance Method Details
#cow_efficiency(parent_meminfo) ⇒ Object
12 13 14 |
# File 'lib/pitchfork/mem_info.rb', line 12 def cow_efficiency(parent_meminfo) shared_memory.to_f / parent_meminfo.rss * 100.0 end |
#update ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/pitchfork/mem_info.rb', line 16 def update info = parse(File.read("/proc/#{@pid}/smaps_rollup")) @pss = info.fetch(:Pss) @rss = info.fetch(:Rss) @shared_memory = info.fetch(:Shared_Clean) + info.fetch(:Shared_Dirty) self end |